Files
geo/server/internal/tenant/compliance/service_test.go
T

37 lines
1.0 KiB
Go
Raw Normal View History

package compliance
import (
"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)
}
}