@@ -5,6 +5,55 @@ import (
55 "testing"
66)
77
8+ const (
9+ buildStreamTestWant = `openapi: 3.0.1
10+ info:
11+ title: Test
12+ description: Test object
13+ termsOfService: ""
14+ contact:
15+ email: ""
16+ license:
17+ name: ""
18+ url: ""
19+ version: ""
20+ externalDocs:
21+ description: ""
22+ url: ""
23+ servers: []
24+ tags: []
25+ paths: {}
26+ components:
27+ schemas:
28+ schema_testing:
29+ properties:
30+ EnumProp:
31+ description: short desc
32+ enum:
33+ - enum
34+ - test
35+ - strSlc
36+ type: enum
37+ intProp:
38+ default: 1337
39+ description: short desc
40+ format: int64
41+ type: integer
42+ type: ""
43+ xml:
44+ name: XML entry test
45+ securitySchemes:
46+ ses_scheme_testing:
47+ flows:
48+ implicit:
49+ authorizationUrl: http://petstore.swagger.io/oauth/dialog
50+ scopes:
51+ read:pets: Read Pets
52+ write:pets: Write to Pets
53+ in: not empty
54+ `
55+ )
56+
857func TestUnitBuild (t * testing.T ) {
958 t .Parallel ()
1059
@@ -114,6 +163,8 @@ func TestUnitGetPathFromFirstElem(t *testing.T) {
114163// QUICK CHECK TESTS ARE COMING WITH NEXT RELEASE.
115164
116165func TestOAS_BuildStream (t * testing.T ) {
166+ t .Parallel ()
167+
117168 tests := []struct {
118169 name string
119170 oas * OAS
@@ -124,27 +175,19 @@ func TestOAS_BuildStream(t *testing.T) {
124175 name : "success" ,
125176 oas : & OAS {
126177 OASVersion : "3.0.1" ,
127- Info : Info {
128- Title : "Test" ,
129- Description : "Test object" ,
130- },
178+ Info : Info {Title : "Test" , Description : "Test object" },
131179 Components : Components {
132180 Component {
133181 Schemas : Schemas {Schema {
134182 Name : "schema_testing" ,
135183 Properties : SchemaProperties {
136184 SchemaProperty {
137- Name : "EnumProp" ,
138- Type : "enum" ,
139- Description : "short desc" ,
140- Enum : []string {"enum" , "test" , "strSlc" },
185+ Name : "EnumProp" , Type : "enum" , Description : "short desc" ,
186+ Enum : []string {"enum" , "test" , "strSlc" },
141187 },
142188 SchemaProperty {
143- Name : "intProp" ,
144- Type : "integer" ,
145- Format : "int64" ,
146- Description : "short desc" ,
147- Default : 1337 ,
189+ Name : "intProp" , Type : "integer" , Format : "int64" ,
190+ Description : "short desc" , Default : 1337 ,
148191 },
149192 },
150193 XML : XMLEntry {Name : "XML entry test" },
@@ -156,70 +199,20 @@ func TestOAS_BuildStream(t *testing.T) {
156199 Type : "implicit" ,
157200 AuthURL : "http://petstore.swagger.io/oauth/dialog" ,
158201 Scopes : SecurityScopes {
159- SecurityScope {
160- Name : "write:pets" ,
161- Description : "Write to Pets" ,
162- },
163- SecurityScope {
164- Name : "read:pets" ,
165- Description : "Read Pets" ,
166- },
202+ SecurityScope {Name : "write:pets" , Description : "Write to Pets" },
203+ SecurityScope {Name : "read:pets" , Description : "Read Pets" },
167204 },
168205 }},
169206 }},
170207 },
171208 },
172209 },
173210 wantErr : false ,
174- wantW : `openapi: 3.0.1
175- info:
176- title: Test
177- description: Test object
178- termsOfService: ""
179- contact:
180- email: ""
181- license:
182- name: ""
183- url: ""
184- version: ""
185- externalDocs:
186- description: ""
187- url: ""
188- servers: []
189- tags: []
190- paths: {}
191- components:
192- schemas:
193- schema_testing:
194- $ref: ""
195- properties:
196- EnumProp:
197- description: short desc
198- enum:
199- - enum
200- - test
201- - strSlc
202- type: enum
203- intProp:
204- default: 1337
205- description: short desc
206- format: int64
207- type: integer
208- type: ""
209- xml:
210- name: XML entry test
211- securitySchemes:
212- ses_scheme_testing:
213- flows:
214- implicit:
215- authorizationUrl: http://petstore.swagger.io/oauth/dialog
216- scopes:
217- read:pets: Read Pets
218- write:pets: Write to Pets
219- in: not empty
220- ` ,
211+ wantW : buildStreamTestWant ,
221212 },
222213 }
214+
215+ t .Parallel ()
223216 for _ , tt := range tests {
224217 t .Run (tt .name , func (t * testing.T ) {
225218 w := & bytes.Buffer {}
0 commit comments