chore: publish IntegraCI build modules 732ec6c83925

This commit is contained in:
dhimaz0445 committed 2026-10-28 08:09:16 +00:00
1 parent 7a84930dea
commit 5f8a24d014
133 files changed
+18990 -2

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
package main
import "testing"
func TestGateFromResponse(t *testing.T) {
cases := []struct {
name, body, want string
}{
{"block", `{"id":"x","gate":{"decision":"block","reason":"r"}}`, "block"},
{"warn", `{"gate":{"decision":"warn"}}`, "warn"},
{"pass", `{"gate":{"decision":"pass"}}`, "pass"},
{"an older platform answers without a gate", `{"id":"x"}`, "pass"},
{"an unknown decision is not invented into a rule", `{"gate":{"decision":"stop"}}`, "pass"},
{"unreadable", `not json`, "pass"},
}
for _, c := range cases {
if got := gateFromResponse([]byte(c.body)).Decision; got != c.want {
t.Errorf("%s: got %q, want %q", c.name, got, c.want)
}
}
}
func TestOnlyBlockStopsTheScan(t *testing.T) {
if err := (platformGate{Decision: "block", Reason: "gate failed (uat: block)"}).err(); err == nil {
t.Fatal("block must fail the scan")
}
for _, d := range []string{"pass", "warn", ""} {
if err := (platformGate{Decision: d}).err(); err != nil {
t.Errorf("%q must not fail the scan: %v", d, err)
}
}
}