Resolves gate-subsystem-2 and gate-subsystem-1. WIRE: gate.Finding.Level is now a typed gate.Level restricted to LevelError/LevelWarn, and Finding.Validate rejects any other value so a mis-typed or empty level fails the gate closed instead of silently downgrading an intended blocker to a pass -- mirroring the fail-closed standard ReviewFinding.Validate already sets in internal/domain/workflow/review_findings.go. WIRE: StageYaegiGate now delegates the blocking decision to gate.Finding.Blocking instead of re-implementing the raw "error" literal, so the script-facing gate.Blocking helper (exposed by gateextract to interpreted .archie/gate.go scripts) and the rule the daemon actually enforces share one source of truth and cannot drift.
71 lines
1.9 KiB
Go
71 lines
1.9 KiB
Go
package gateextract
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestSymbolsContainsExpectedEntries(t *testing.T) {
|
|
pkgKey := "github.com/samcharles93/archie-core/internal/gate/gate"
|
|
pkg, ok := Symbols[pkgKey]
|
|
if !ok {
|
|
t.Fatalf("Symbols missing key %q", pkgKey)
|
|
}
|
|
|
|
// Blocking must be a function.
|
|
if v, ok := pkg["Blocking"]; !ok {
|
|
t.Error("Blocking not found in Symbols")
|
|
} else if v.Kind() != reflect.Func {
|
|
t.Errorf("Blocking kind = %v, want Func", v.Kind())
|
|
}
|
|
|
|
// LevelError and LevelWarn must be the exported level constants.
|
|
for _, name := range []string{"LevelError", "LevelWarn"} {
|
|
if v, ok := pkg[name]; !ok {
|
|
t.Errorf("%s not found in Symbols", name)
|
|
} else if v.Kind() != reflect.String {
|
|
t.Errorf("%s kind = %v, want String", name, v.Kind())
|
|
}
|
|
}
|
|
|
|
// Finding must be a pointer type.
|
|
if v, ok := pkg["Finding"]; !ok {
|
|
t.Error("Finding not found in Symbols")
|
|
} else if v.Kind() != reflect.Pointer {
|
|
t.Errorf("Finding kind = %v, want Ptr", v.Kind())
|
|
}
|
|
|
|
// Level must be a pointer to the defined string type, so interpreted
|
|
// scripts can resolve Finding.Level's named type.
|
|
if v, ok := pkg["Level"]; !ok {
|
|
t.Error("Level not found in Symbols")
|
|
} else if v.Kind() != reflect.Pointer {
|
|
t.Errorf("Level kind = %v, want Ptr", v.Kind())
|
|
}
|
|
|
|
// GateContext must be a pointer type.
|
|
if v, ok := pkg["GateContext"]; !ok {
|
|
t.Error("GateContext not found in Symbols")
|
|
} else if v.Kind() != reflect.Pointer {
|
|
t.Errorf("GateContext kind = %v, want Ptr", v.Kind())
|
|
}
|
|
}
|
|
|
|
func TestSymbolsNoUnexpectedEntries(t *testing.T) {
|
|
pkgKey := "github.com/samcharles93/archie-core/internal/gate/gate"
|
|
pkg := Symbols[pkgKey]
|
|
expected := map[string]bool{
|
|
"Blocking": true,
|
|
"LevelError": true,
|
|
"LevelWarn": true,
|
|
"Finding": true,
|
|
"GateContext": true,
|
|
"Level": true,
|
|
}
|
|
for name := range pkg {
|
|
if !expected[name] {
|
|
t.Errorf("unexpected symbol %q in gateextract Symbols", name)
|
|
}
|
|
}
|
|
}
|