Skip to content

Commit d3eed09

Browse files
committed
Add more tests
1 parent 9d1ce13 commit d3eed09

File tree

2 files changed

+68692
-0
lines changed

2 files changed

+68692
-0
lines changed

tools/cli/internal/cli/split/split_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,43 @@ func TestSplitPrivatePreviewRun(t *testing.T) {
7878
require.Contains(t, info.Spec.Paths.Map(), "/api/atlas/v2/groups")
7979
}
8080

81+
func TestSplitMulitplePreviewsRun(t *testing.T) {
82+
fs := afero.NewMemMapFs()
83+
opts := &Opts{
84+
basePath: "../../../test/data/base_spec_with_multiple_private_and_public_previews.json",
85+
outputPath: "foas.yaml",
86+
fs: fs,
87+
}
88+
89+
if err := opts.Run(); err != nil {
90+
t.Fatalf("Run() unexpected error: %v", err)
91+
}
92+
93+
// private preview feature 1
94+
info, err := loadRunResultOas(fs, "foas-private-preview-new-feature.yaml")
95+
require.NoError(t, err)
96+
97+
// check paths has only one
98+
require.Len(t, info.Spec.Paths.Map(), 1)
99+
require.Contains(t, info.Spec.Paths.Map(), "/api/atlas/v2/groups")
100+
101+
// private preview feature 2
102+
info, err = loadRunResultOas(fs, "foas-private-preview-secrets-feature.yaml")
103+
require.NoError(t, err)
104+
105+
// check paths has only one
106+
require.Len(t, info.Spec.Paths.Map(), 1)
107+
require.Contains(t, info.Spec.Paths.Map(), "/api/atlas/v2/groups/{groupId}/serviceAccounts/{clientId}/secrets")
108+
109+
// public preview
110+
info, err = loadRunResultOas(fs, "foas-preview.yaml")
111+
require.NoError(t, err)
112+
113+
// check paths has only one
114+
require.Len(t, info.Spec.Paths.Map(), 1)
115+
require.Contains(t, info.Spec.Paths.Map(), "/api/atlas/v2/groups/{groupId}/serviceAccounts")
116+
}
117+
81118
func TestOpts_PreRunE(t *testing.T) {
82119
testCases := []struct {
83120
wantErr require.ErrorAssertionFunc

0 commit comments

Comments
 (0)