Files

26 lines
1013 B
Go
Raw Permalink Normal View History

package saas
import "testing"
func TestInitialConsentsRequireExplicitSelection(t *testing.T) {
for _, tc := range []struct {
name string
selection InitialConsentSelection
invalid bool
}{
{"legacy omission", InitialConsentSelection{}, false},
{"skip", InitialConsentSelection{Confirmed: true}, false},
{"subset", InitialConsentSelection{Types: []string{ConsentTranscriptStorage}, Confirmed: true}, false},
{"all", InitialConsentSelection{Types: consentTypes, Confirmed: true}, false},
{"unconfirmed", InitialConsentSelection{Types: []string{ConsentPersonalMemory}}, true},
{"unknown", InitialConsentSelection{Types: []string{"voice_chat"}, Confirmed: true}, true},
{"duplicate", InitialConsentSelection{Types: []string{ConsentPersonalMemory, ConsentPersonalMemory}, Confirmed: true}, true},
} {
t.Run(tc.name, func(t *testing.T) {
if err := ValidateInitialConsents(tc.selection); (err != nil) != tc.invalid {
t.Fatalf("error=%v invalid=%v", err, tc.invalid)
}
})
}
}