package compliance import ( "strings" "testing" sharedcompliance "github.com/geo-platform/tenant-api/internal/shared/compliance" ) func TestDecideMandatoryBlocksAnyHit(t *testing.T) { levels := []string{"block", "high", "medium", "info"} for _, level := range levels { level := level t.Run(level, func(t *testing.T) { got := decide("mandatory", &level, 1) if got != sharedcompliance.GateDecisionBlock { t.Fatalf("decide mandatory %s hit = %s, want %s", level, got, sharedcompliance.GateDecisionBlock) } }) } } func TestDecideAdvisoryNeedsAckOnAnyHit(t *testing.T) { level := "info" got := decide("advisory", &level, 1) if got != sharedcompliance.GateDecisionNeedsAck { t.Fatalf("decide advisory hit = %s, want %s", got, sharedcompliance.GateDecisionNeedsAck) } } func TestDecidePassesWithoutHits(t *testing.T) { level := "block" got := decide("mandatory", &level, 0) if got != sharedcompliance.GateDecisionPass { t.Fatalf("decide without hits = %s, want %s", got, sharedcompliance.GateDecisionPass) } } func TestComplianceAIPointCostUsesOutputBoundary(t *testing.T) { t.Parallel() tests := []struct { name string chars int baseChars int want int }{ {name: "empty output minimum", chars: 0, baseChars: 1000, want: 1}, {name: "single char", chars: 1, baseChars: 1000, want: 1}, {name: "exactly one base", chars: 1000, baseChars: 1000, want: 1}, {name: "one over base", chars: 1001, baseChars: 1000, want: 2}, {name: "default base", chars: 2000, baseChars: 0, want: 2}, } for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := calculateAIPointCost(tt.chars, tt.baseChars); got != tt.want { t.Fatalf("calculateAIPointCost(%d, %d) = %d, want %d", tt.chars, tt.baseChars, got, tt.want) } }) } } func TestComplianceAIPointCharsTrimWhitespace(t *testing.T) { t.Parallel() got := countAIPointChars(" " + strings.Repeat("字", 1001) + "\n") if got != 1001 { t.Fatalf("countAIPointChars = %d, want 1001", got) } }