@@ -104,9 +104,10 @@ describe("deployment checks", () => {
104104 // Catches: a background check changing a live deployment.
105105 const results : DeploymentCheckResult [ ] = [
106106 { outcome : "pass" , id : "check_1" , retryable : false } ,
107- { outcome : "fail" , id : "check_2" , retryable : false } ,
108- { outcome : "unavailable" , id : "check_3" , retryable : false } ,
109- { outcome : "unavailable" , id : "check_4" , retryable : true } ,
107+ { outcome : "flagged" , id : "check_2" , retryable : false } ,
108+ { outcome : "fail" , id : "check_3" , retryable : false } ,
109+ { outcome : "unavailable" , id : "check_4" , retryable : false } ,
110+ { outcome : "unavailable" , id : "check_5" , retryable : true } ,
110111 ] ;
111112 for ( const result of results ) {
112113 const { deployment } = await createDeployment ( prisma ) ;
@@ -127,12 +128,17 @@ describe("deployment checks", () => {
127128
128129 postgresTest ( "checks what the plugin chose, labelled with its mode" , async ( { prisma } ) => {
129130 // Catches: a gate or shadow deploy not checked, a skipped one checked, an image reference
130- // the checker can't use sent, the plugin asked about the wrong org or deployment, or an org
131- // id in the metric attributes.
131+ // the checker can't use sent, the plugin asked about the wrong org or deployment, an org id
132+ // in the metric attributes, or a flagged answer missing from the counter the deploy scan
133+ // alert reads.
132134 const metrics = createInMemoryMetrics ( ) ;
133135 const telemetry = deploymentCheckTelemetry ( metrics . meter ) ;
134- const run = async ( decision : DeploymentCheckDecision , imageReference ?: string | null ) => {
135- const plugin = testPlugin ( { decision } ) ;
136+ const run = async (
137+ decision : DeploymentCheckDecision ,
138+ imageReference ?: string | null ,
139+ result ?: DeploymentCheckResult
140+ ) => {
141+ const plugin = testPlugin ( { decision, result } ) ;
136142 const { deployment, organization, project } = await createDeployment ( prisma , {
137143 imageReference,
138144 } ) ;
@@ -175,6 +181,13 @@ describe("deployment checks", () => {
175181 ] ) ;
176182 }
177183
184+ const flagged = await run ( SHADOW , undefined , {
185+ outcome : "flagged" ,
186+ id : "check_flagged" ,
187+ retryable : false ,
188+ } ) ;
189+ expect ( flagged . outcome ) . toBe ( "flagged" ) ;
190+
178191 // The reader also exports every 100 ms, and an earlier export holds partial totals. With
179192 // cumulative temporality the latest export holds every point.
180193 const points = ( ( await latestMetrics ( metrics ) ) ?. scopeMetrics ?? [ ] )
@@ -184,6 +197,7 @@ describe("deployment checks", () => {
184197 expect . arrayContaining ( [
185198 { mode : "shadow" , selected_by : "sampled" , outcome : "pass" } ,
186199 { mode : "gate" , selected_by : "always" , outcome : "pass" } ,
200+ { mode : "shadow" , selected_by : "sampled" , outcome : "flagged" } ,
187201 ] )
188202 ) ;
189203 for ( const point of points ?? [ ] ) {
0 commit comments