MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestGitOpsCheckReleaseRiskLevel

Function TestGitOpsCheckReleaseRiskLevel

backend/tests/gitops_test.go:157–198  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

155}
156
157func TestGitOpsCheckReleaseRiskLevel(t *testing.T) {
158 t.Parallel()
159 a := require.New(t)
160 ctx := context.Background()
161 ctl := &controller{}
162 ctx, err := ctl.StartServerWithExternalPg(ctx)
163 a.NoError(err)
164 defer ctl.Close(ctx)
165
166 database, pgContainer := ctl.createTestPostgreSQLDatabase(ctx, t)
167 defer pgContainer.Close(ctx)
168
169 setupSheet, err := ctl.sheetServiceClient.CreateSheet(ctx, connect.NewRequest(&v1pb.CreateSheetRequest{
170 Parent: ctl.project.Name,
171 Sheet: &v1pb.Sheet{
172 Content: []byte("CREATE TABLE public.risk_check_target (id INTEGER PRIMARY KEY);"),
173 },
174 }))
175 a.NoError(err)
176 a.NoError(ctl.changeDatabase(ctx, ctl.project, database, setupSheet.Msg, false))
177
178 release := &v1pb.Release{
179 Type: v1pb.Release_VERSIONED,
180 Files: []*v1pb.Release_File{
181 {
182 Path: "migrations/002__drop_risk_check_target.sql",
183 Version: "002",
184 Statement: []byte("DROP TABLE public.risk_check_target;"),
185 },
186 },
187 }
188
189 checkResp, err := ctl.releaseServiceClient.CheckRelease(ctx, connect.NewRequest(&v1pb.CheckReleaseRequest{
190 Parent: ctl.project.Name,
191 Release: release,
192 Targets: []string{database.Name},
193 }))
194 a.NoError(err)
195 a.Len(checkResp.Msg.Results, 1)
196 a.Equal(v1pb.RiskLevel_HIGH, checkResp.Msg.Results[0].RiskLevel)
197 a.Equal(v1pb.RiskLevel_HIGH, checkResp.Msg.RiskLevel)
198}
199
200func TestGitOpsCheckReleaseVCSUserTracking(t *testing.T) {
201 t.Parallel()

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
changeDatabaseMethod · 0.95
LenMethod · 0.80
CloseMethod · 0.65
CreateSheetMethod · 0.65
CheckReleaseMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected