@@ -146,6 +146,45 @@ paths:
146146 }
147147}
148148
149+ func TestConfig_Parse (t * testing.T ) {
150+ testcases := []struct {
151+ name string
152+ config * openapi.Config
153+ test func (t * testing.T , config * openapi.Config , err error )
154+ }{
155+ {
156+ name : "empty server" ,
157+ config : & openapi.Config {},
158+ test : func (t * testing.T , config * openapi.Config , err error ) {
159+ require .NoError (t , err )
160+ require .Len (t , config .Servers , 1 )
161+ require .Equal (t , "/" , config .Servers [0 ].Url )
162+ },
163+ },
164+ {
165+ name : "one server" ,
166+ config : openapitest .NewConfig ("3.1.0" , openapitest .WithServer ("/foo" , "" )),
167+ test : func (t * testing.T , config * openapi.Config , err error ) {
168+ require .NoError (t , err )
169+ require .Len (t , config .Servers , 1 )
170+ require .Equal (t , "/foo" , config .Servers [0 ].Url )
171+ },
172+ },
173+ }
174+
175+ for _ , tc := range testcases {
176+ tc := tc
177+ t .Run (tc .name , func (t * testing.T ) {
178+ t .Parallel ()
179+ err := tc .config .Parse (& dynamic.Config {
180+ Data : tc .config ,
181+ Info : dynamictest .NewConfigInfo (),
182+ }, & dynamictest.Reader {})
183+ tc .test (t , tc .config , err )
184+ })
185+ }
186+ }
187+
149188func TestResponses (t * testing.T ) {
150189 testdata := []struct {
151190 name string
@@ -380,7 +419,7 @@ func TestPetStore_Response(t *testing.T) {
380419 require .Nil (t , m )
381420}
382421
383- func TestPetStore_Paramters (t * testing.T ) {
422+ func TestPetStore_Parameters (t * testing.T ) {
384423 config := & openapi.Config {}
385424 err := yaml .Unmarshal ([]byte (petstore ), & config )
386425 require .NoError (t , err )
0 commit comments