prompt_repository_test.go 855 B

12345678910111213141516171819202122232425
  1. package securityaudit
  2. import "testing"
  3. func TestShouldStorePromptAuditEvent(t *testing.T) {
  4. tests := []struct {
  5. name string
  6. storePassEvents bool
  7. decision EventDecision
  8. want bool
  9. }{
  10. {name: "pass disabled", storePassEvents: false, decision: EventPass, want: false},
  11. {name: "flag disabled", storePassEvents: false, decision: EventFlag, want: true},
  12. {name: "critical disabled", storePassEvents: false, decision: EventCritical, want: true},
  13. {name: "pass enabled", storePassEvents: true, decision: EventPass, want: true},
  14. }
  15. for _, tt := range tests {
  16. t.Run(tt.name, func(t *testing.T) {
  17. if got := shouldStorePromptAuditEvent(tt.decision, tt.storePassEvents); got != tt.want {
  18. t.Fatalf("shouldStorePromptAuditEvent(%q, %t) = %t, want %t", tt.decision, tt.storePassEvents, got, tt.want)
  19. }
  20. })
  21. }
  22. }