@@ -20,6 +20,7 @@ import (
2020
2121 "github.com/go-openapi/swag"
2222 "github.com/stretchr/testify/assert"
23+ "github.com/stretchr/testify/require"
2324)
2425
2526var items = Items {
@@ -74,9 +75,8 @@ const itemsJSON = `{
7475
7576func TestIntegrationItems (t * testing.T ) {
7677 var actual Items
77- if assert .NoError (t , json .Unmarshal ([]byte (itemsJSON ), & actual )) {
78- assert .EqualValues (t , actual , items )
79- }
78+ require .NoError (t , json .Unmarshal ([]byte (itemsJSON ), & actual ))
79+ assert .EqualValues (t , actual , items )
8080
8181 assertParsesJSON (t , itemsJSON , items )
8282}
@@ -152,38 +152,38 @@ func TestItemsBuilder(t *testing.T) {
152152
153153func TestJSONLookupItems (t * testing.T ) {
154154 res , err := items .JSONLookup ("$ref" )
155- if ! assert .NoError (t , err ) {
156- t . FailNow ( )
157- return
158- }
159- if assert . IsType ( t , & Ref {}, res ) {
160- ref := res .(* Ref )
161- assert . EqualValues (t , MustCreateRef ( "Dog" ), * ref )
162- }
155+ require .NoError (t , err )
156+ require . NotNil ( t , res )
157+ require . IsType ( t , & Ref {}, res )
158+
159+ var ok bool
160+ ref , ok := res .(* Ref )
161+ require . True (t , ok )
162+ assert . EqualValues ( t , MustCreateRef ( "Dog" ), * ref )
163163
164164 var max * float64
165165 res , err = items .JSONLookup ("maximum" )
166- if ! assert .NoError (t , err ) || ! assert .NotNil (t , res ) || ! assert .IsType (t , max , res ) {
167- t .FailNow ()
168- return
169- }
170- max = res .(* float64 )
171- assert .Equal (t , float64 (100 ), * max )
166+ require .NoError (t , err )
167+ require .NotNil (t , res )
168+ require .IsType (t , max , res )
169+
170+ max , ok = res .(* float64 )
171+ require .True (t , ok )
172+ assert .InDelta (t , float64 (100 ), * max , epsilon )
172173
173174 var f string
174175 res , err = items .JSONLookup ("collectionFormat" )
175- if ! assert .NoError (t , err ) || ! assert .NotNil (t , res ) || ! assert .IsType (t , f , res ) {
176- t .FailNow ()
177- return
178- }
179- f = res .(string )
176+ require .NoError (t , err )
177+ require .NotNil (t , res )
178+ require .IsType (t , f , res )
179+
180+ f , ok = res .(string )
181+ require .True (t , ok )
180182 assert .Equal (t , "csv" , f )
181183
182184 res , err = items .JSONLookup ("unknown" )
183- if ! assert .Error (t , err ) || ! assert .Nil (t , res ) {
184- t .FailNow ()
185- return
186- }
185+ require .Error (t , err )
186+ require .Nil (t , res )
187187}
188188
189189func TestItemsWithValidation (t * testing.T ) {
0 commit comments