Skip to content

Commit cca351a

Browse files
added unit tests
1 parent 2d8213a commit cca351a

File tree

2 files changed

+79401
-0
lines changed

2 files changed

+79401
-0
lines changed

tools/cli/internal/cli/versions/versions_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,41 @@ func TestVersion_RunWithPreview(t *testing.T) {
7575
assert.Contains(t, string(b), "preview")
7676
}
7777

78+
func TestVersion_RunWithUpcoming(t *testing.T) {
79+
fs := afero.NewMemMapFs()
80+
opts := &Opts{
81+
basePath: "../../../test/data/openapi_with_upcoming.json",
82+
outputPath: "foas.json",
83+
fs: fs,
84+
env: "dev",
85+
}
86+
87+
require.NoError(t, opts.Run())
88+
b, err := afero.ReadFile(fs, opts.outputPath)
89+
require.NoError(t, err)
90+
91+
// Check initial versions
92+
assert.NotEmpty(t, b)
93+
assert.Contains(t, string(b), "2023-02-01")
94+
assert.Contains(t, string(b), "2025-09-22.upcoming")
95+
96+
opts = &Opts{
97+
basePath: "../../../test/data/openapi_with_upcoming.json",
98+
outputPath: "foas.json",
99+
fs: fs,
100+
env: "prod",
101+
}
102+
103+
require.NoError(t, opts.Run())
104+
b, err = afero.ReadFile(fs, opts.outputPath)
105+
require.NoError(t, err)
106+
107+
assert.NotEmpty(t, b)
108+
assert.Contains(t, string(b), "2023-02-01")
109+
// Upcoming is only available for dev env
110+
assert.NotContains(t, string(b), "2025-09-22.upcoming")
111+
}
112+
78113
func TestVersion_RunStabilityLevelPreviewAndPrivatePreview(t *testing.T) {
79114
fs := afero.NewMemMapFs()
80115
opts := &Opts{

0 commit comments

Comments
 (0)