@@ -39,6 +39,18 @@ func TestVersions_PublicPreview(t *testing.T) {
3939 assert .Equal (t , []string {"2023-01-01" , "2023-02-01" , "preview" }, versions )
4040}
4141
42+ func TestVersions_UpcomingAPI (t * testing.T ) {
43+ versions , err := ExtractVersionsWithEnv (NewVersionedResponsesWithUpcoming (t ), "" )
44+ require .NoError (t , err )
45+ assert .Equal (t , []string {"2023-01-01" , "2025-09-22.upcoming" }, versions )
46+ }
47+
48+ func TestVersions_UpcomingAndStableAPI (t * testing.T ) {
49+ versions , err := ExtractVersionsWithEnv (NewVersionedResponsesWithUpcomingAndStable (t ), "" )
50+ require .NoError (t , err )
51+ assert .Equal (t , []string {"2023-01-01" , "2025-09-22" }, versions )
52+ }
53+
4254func TestVersions_InvalidPreviewData (t * testing.T ) {
4355 r := NewVersionedResponses (t )
4456 // override the extension so something invalid like "public": true
@@ -194,3 +206,80 @@ func NewVersionedResponses(t *testing.T) *openapi3.T {
194206
195207 return oas
196208}
209+
210+ func NewVersionedResponsesWithUpcoming (t * testing.T ) * openapi3.T {
211+ t .Helper ()
212+ inputPath := & openapi3.Paths {}
213+
214+ extension := map [string ]any {
215+ "x-xgen-version" : "2023-01-01" ,
216+ }
217+ response := & openapi3.ResponseRef {
218+ Value : & openapi3.Response {
219+ Extensions : extension ,
220+ Content : map [string ]* openapi3.MediaType {
221+ "application/vnd.atlas.2023-01-01+json" : {},
222+ "application/vnd.atlas.2025-09-22.upcoming+json" : {},
223+ },
224+ },
225+ }
226+
227+ responses := & openapi3.Responses {}
228+ responses .Set ("200" , response )
229+
230+ inputPath .Set ("pathBase1" , & openapi3.PathItem {
231+ Extensions : nil ,
232+ Ref : "" ,
233+ Summary : "pathBase1" ,
234+ Description : "pathBase1Description" ,
235+ Get : & openapi3.Operation {
236+ Tags : []string {"tag1" },
237+ Responses : responses ,
238+ },
239+ })
240+
241+ oas := & openapi3.T {
242+ Paths : inputPath ,
243+ }
244+
245+ return oas
246+ }
247+
248+ func NewVersionedResponsesWithUpcomingAndStable (t * testing.T ) * openapi3.T {
249+ t .Helper ()
250+ inputPath := & openapi3.Paths {}
251+
252+ extension := map [string ]any {
253+ "x-xgen-version" : "2023-01-01" ,
254+ }
255+ response := & openapi3.ResponseRef {
256+ Value : & openapi3.Response {
257+ Extensions : extension ,
258+ Content : map [string ]* openapi3.MediaType {
259+ "application/vnd.atlas.2023-01-01+json" : {},
260+ "application/vnd.atlas.2025-09-22.upcoming+json" : {},
261+ "application/vnd.atlas.2025-09-22+json" : {},
262+ },
263+ },
264+ }
265+
266+ responses := & openapi3.Responses {}
267+ responses .Set ("200" , response )
268+
269+ inputPath .Set ("pathBase1" , & openapi3.PathItem {
270+ Extensions : nil ,
271+ Ref : "" ,
272+ Summary : "pathBase1" ,
273+ Description : "pathBase1Description" ,
274+ Get : & openapi3.Operation {
275+ Tags : []string {"tag1" },
276+ Responses : responses ,
277+ },
278+ })
279+
280+ oas := & openapi3.T {
281+ Paths : inputPath ,
282+ }
283+
284+ return oas
285+ }
0 commit comments