1515package sunset
1616
1717import (
18+ "encoding/json"
19+ "reflect"
1820 "testing"
1921
22+ "github.com/mongodb/openapi/tools/cli/internal/openapi/sunset"
2023 "github.com/spf13/afero"
2124 "github.com/stretchr/testify/assert"
2225 "github.com/stretchr/testify/require"
@@ -28,10 +31,106 @@ func TestList_Run(t *testing.T) {
2831 basePath : "../../../test/data/base_spec.json" ,
2932 outputPath : "foas.json" ,
3033 fs : fs ,
34+ format : "json" ,
35+ from : "2024-09-22" ,
36+ to : "2026-09-22" ,
3137 }
3238
3339 require .NoError (t , opts .Run ())
3440 b , err := afero .ReadFile (fs , opts .outputPath )
3541 require .NoError (t , err )
3642 assert .NotEmpty (t , b )
43+ var results []* sunset.Sunset
44+ require .NoError (t , json .Unmarshal (b , & results ))
45+ if ! reflect .DeepEqual (results , expectedResults ) {
46+ gotPretty , _ := json .MarshalIndent (results , "" , " " )
47+ wantPretty , _ := json .MarshalIndent (expectedResults , "" , " " )
48+ t .Errorf ("mismatch:\n Got:\n %s\n Want:\n %s" , string (gotPretty ), string (wantPretty ))
49+ }
50+ }
51+
52+ var expectedResults = []* sunset.Sunset {
53+ {Operation : "GET" , Path : "/api/atlas/v2/example/info" , SunsetDate : "2025-06-01" , Team : "APIx" ,
54+ Version : "2023-01-01" },
55+ {Operation : "GET" ,
56+ Path : "/api/atlas/v2/federationSettings/{federationSettingsId}/identityProviders/{identityProviderId}" ,
57+ SunsetDate : "2025-01-01" , Team : "IAM" , Version : "2023-01-01" },
58+ {Operation : "PATCH" ,
59+ Path : "/api/atlas/v2/federationSettings/{federationSettingsId}/identityProviders/{identityProviderId}" ,
60+ SunsetDate : "2025-01-01" , Team : "IAM" , Version : "2023-01-01" },
61+ {Operation : "PATCH" , Path : "/api/atlas/v2/groups/{groupId}/alerts/{alertId}" , SunsetDate : "2025-05-30" ,
62+ Team : "CAP" , Version : "2023-01-01" },
63+ {Operation : "GET" , Path : "/api/atlas/v2/groups/{groupId}/backup/exportBuckets" , SunsetDate : "2025-05-30" ,
64+ Team : "Backup - Atlas" , Version : "2023-01-01" },
65+ {Operation : "POST" , Path : "/api/atlas/v2/groups/{groupId}/backup/exportBuckets" ,
66+ SunsetDate : "2025-05-30" , Team : "Backup - Atlas" , Version : "2023-01-01" },
67+ {Operation : "GET" , Path : "/api/atlas/v2/groups/{groupId}/backup/exportBuckets/{exportBucketId}" ,
68+ SunsetDate : "2025-05-30" , Team : "Backup - Atlas" , Version : "2023-01-01" },
69+ {Operation : "GET" , Path : "/api/atlas/v2/groups/{groupId}/backupCompliancePolicy" ,
70+ SunsetDate : "2024-10-01" , Team : "Backup - Atlas" , Version : "2023-01-01" },
71+ {Operation : "PUT" , Path : "/api/atlas/v2/groups/{groupId}/backupCompliancePolicy" ,
72+ SunsetDate : "2024-10-01" , Team : "Backup - Atlas" , Version : "2023-01-01" },
73+ {Operation : "POST" , Path : "/api/atlas/v2/groups/{groupId}/clusters" ,
74+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
75+ {Operation : "DELETE" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}" ,
76+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
77+ {Operation : "GET" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}" ,
78+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
79+ {Operation : "PATCH" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}" ,
80+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
81+ {Operation : "POST" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes" ,
82+ SunsetDate : "2025-06-01" , Team : "Search Web Platform" , Version : "2023-01-01" },
83+ {Operation : "GET" ,
84+ Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{databaseName}/{collectionName}" ,
85+ SunsetDate : "2025-06-01" , Team : "Search Web Platform" , Version : "2023-01-01" },
86+ {Operation : "DELETE" ,
87+ Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId}" ,
88+ SunsetDate : "2025-06-01" , Team : "Search Web Platform" , Version : "2023-01-01" },
89+ {Operation : "GET" ,
90+ Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId}" ,
91+ SunsetDate : "2025-06-01" , Team : "Search Web Platform" , Version : "2023-01-01" },
92+ {Operation : "PATCH" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId}" ,
93+ SunsetDate : "2025-06-01" , Team : "Search Web Platform" , Version : "2023-01-01" },
94+ {Operation : "GET" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/globalWrites" ,
95+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
96+ {Operation : "DELETE" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/globalWrites/customZoneMapping" ,
97+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
98+ {Operation : "POST" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/globalWrites/customZoneMapping" ,
99+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
100+ {Operation : "DELETE" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/globalWrites/managedNamespaces" ,
101+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
102+ {Operation : "POST" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/globalWrites/managedNamespaces" ,
103+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
104+ {Operation : "GET" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs" ,
105+ SunsetDate : "2025-06-01" , Team : "Atlas" , Version : "2023-01-01" },
106+ {Operation : "PATCH" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs" ,
107+ SunsetDate : "2025-06-01" , Team : "Atlas" , Version : "2023-01-01" },
108+ {Operation : "POST" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/restartPrimaries" ,
109+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
110+ {Operation : "DELETE" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/deployment" ,
111+ SunsetDate : "2026-03-01" , Team : "Search Web Platform" , Version : "2023-01-01" },
112+ {Operation : "GET" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/deployment" ,
113+ SunsetDate : "2026-03-01" , Team : "Search Web Platform" , Version : "2023-01-01" },
114+ {Operation : "PATCH" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/deployment" ,
115+ SunsetDate : "2026-03-01" , Team : "Search Web Platform" , Version : "2023-01-01" },
116+ {Operation : "POST" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/deployment" ,
117+ SunsetDate : "2026-03-01" , Team : "Search Web Platform" , Version : "2023-01-01" },
118+ {Operation : "GET" , Path : "/api/atlas/v2/groups/{groupId}/clusters/{hostName}/logs/{logName}.gz" ,
119+ SunsetDate : "2025-06-01" , Team : "Atlas Dedicated" , Version : "2023-01-01" },
120+ {Operation : "GET" , Path : "/api/atlas/v2/groups/{groupId}/invites" , SunsetDate : "2024-10-04" , Team : "IAM" ,
121+ Version : "2023-01-01" },
122+ {Operation : "PATCH" , Path : "/api/atlas/v2/groups/{groupId}/invites" ,
123+ SunsetDate : "2024-10-04" , Team : "IAM" , Version : "2023-01-01" },
124+ {Operation : "POST" , Path : "/api/atlas/v2/groups/{groupId}/invites" , SunsetDate : "2024-10-04" , Team : "IAM" ,
125+ Version : "2023-01-01" },
126+ {Operation : "DELETE" , Path : "/api/atlas/v2/groups/{groupId}/invites/{invitationId}" , SunsetDate : "2024-10-04" ,
127+ Team : "IAM" , Version : "2023-01-01" },
128+ {Operation : "GET" , Path : "/api/atlas/v2/groups/{groupId}/invites/{invitationId}" , SunsetDate : "2024-10-04" ,
129+ Team : "IAM" , Version : "2023-01-01" },
130+ {Operation : "PATCH" , Path : "/api/atlas/v2/groups/{groupId}/invites/{invitationId}" , SunsetDate : "2024-10-04" ,
131+ Team : "IAM" , Version : "2023-01-01" },
132+ {Operation : "POST" , Path : "/api/atlas/v2/groups/{groupId}/liveMigrations" , SunsetDate : "2025-05-30" ,
133+ Team : "Atlas Migrations" , Version : "2023-01-01" },
134+ {Operation : "POST" , Path : "/api/atlas/v2/groups/{groupId}/liveMigrations/validate" , SunsetDate : "2025-05-30" ,
135+ Team : "Atlas Migrations" , Version : "2023-01-01" },
37136}
0 commit comments