1package config
2
3import "testing"
4
5func TestCheckMailboxName(t *testing.T) {
6 tests := []struct {
7 name string
8 allowInbox bool
9 want string
10 wantInbox bool
11 wantErr bool
12 }{
13 {"Introbox", false, "Introbox", false, false},
14 {"inbox/Intro", false, "Inbox/Intro", false, false},
15 {"Inbox", true, "Inbox", false, false},
16 {"Inbox", false, "", true, true},
17 {"bad//name", false, "", false, true},
18 }
19
20 for _, test := range tests {
21 t.Run(test.name, func(t *testing.T) {
22 got, gotInbox, err := CheckMailboxName(test.name, test.allowInbox)
23 if (err != nil) != test.wantErr {
24 t.Fatalf("CheckMailboxName error %v, want error %v", err, test.wantErr)
25 }
26 if got != test.want {
27 t.Fatalf("CheckMailboxName name %q, want %q", got, test.want)
28 }
29 if gotInbox != test.wantInbox {
30 t.Fatalf("CheckMailboxName isInbox %v, want %v", gotInbox, test.wantInbox)
31 }
32 })
33 }
34}
35