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

Function TestValidateFallbackApprovalExpr

backend/common/cel_test.go:146–190  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144}
145
146func TestValidateFallbackApprovalExpr(t *testing.T) {
147 tests := []struct {
148 name string
149 expression string
150 wantErr bool
151 }{
152 {
153 name: "valid project_id condition",
154 expression: `resource.project_id == "proj-123"`,
155 wantErr: false,
156 },
157 {
158 name: "valid true condition",
159 expression: `true`,
160 wantErr: false,
161 },
162 {
163 name: "invalid environment_id condition",
164 expression: `resource.environment_id == "prod"`,
165 wantErr: true,
166 },
167 {
168 name: "invalid statement condition",
169 expression: `statement.affected_rows > 100`,
170 wantErr: true,
171 },
172 {
173 name: "empty condition",
174 expression: ``,
175 wantErr: false, // empty is allowed
176 },
177 }
178
179 for _, tt := range tests {
180 t.Run(tt.name, func(t *testing.T) {
181 a := require.New(t)
182 err := ValidateFallbackApprovalExpr(tt.expression)
183 if tt.wantErr {
184 a.Error(err)
185 } else {
186 a.NoError(err)
187 }
188 })
189 }
190}
191
192func TestApprovalFactorsIncludesRiskLevel(t *testing.T) {
193 a := require.New(t)

Callers

nothing calls this directly

Calls 3

RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected