Skip to content

Commit ef99e7a

Browse files
committed
Add unit test
1 parent 9a3fdff commit ef99e7a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,26 @@ func TestSplitMulitplePreviewsRun(t *testing.T) {
115115
require.Contains(t, info.Spec.Paths.Map(), "/api/atlas/v2/groups/{groupId}/serviceAccounts")
116116
}
117117

118+
func TestInjectSha_Run(t *testing.T) {
119+
fs := afero.NewMemMapFs()
120+
opts := &Opts{
121+
basePath: "../../../test/data/base_spec.json",
122+
outputPath: "foas.yaml",
123+
fs: fs,
124+
gitSha: "123456",
125+
}
126+
127+
if err := opts.Run(); err != nil {
128+
t.Fatalf("Run() unexpected error: %v", err)
129+
}
130+
131+
result, err := loadRunResultOas(fs, "foas-2023-01-01.yaml")
132+
require.NoError(t, err)
133+
// check sha
134+
require.Contains(t, result.Spec.Info.Extensions, "x-xgen-sha")
135+
require.Equal(t, "123456", result.Spec.Info.Extensions["x-xgen-sha"])
136+
}
137+
118138
func TestOpts_PreRunE(t *testing.T) {
119139
testCases := []struct {
120140
wantErr require.ErrorAssertionFunc

0 commit comments

Comments
 (0)