-
Notifications
You must be signed in to change notification settings - Fork 0
/
gmail_test.go
54 lines (48 loc) · 1.17 KB
/
gmail_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package gmailalert_test
import (
"os"
"testing"
"github.com/aculclasure/gmailalert"
)
func TestNewGmailClient(t *testing.T) {
t.Parallel()
testCases := map[string]struct {
input gmailalert.GmailClientConfig
errExpected bool
}{
"Empty credentials file returns an error": {
input: gmailalert.GmailClientConfig{
CredentialsFile: "",
TokenFile: "token.json",
UserInput: os.Stdin,
RedirectSvrPort: 9999,
},
errExpected: true,
},
"Invalid user input source returns an error": {
input: gmailalert.GmailClientConfig{
CredentialsFile: "credentials.json",
UserInput: nil,
RedirectSvrPort: 9999,
},
errExpected: true,
},
"Invalid redirect server port returns an error": {
input: gmailalert.GmailClientConfig{
CredentialsFile: "credentials.json",
UserInput: os.Stdin,
RedirectSvrPort: -9999,
},
errExpected: true,
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
_, err := gmailalert.NewGmailClient(tc.input)
errReceived := err != nil
if tc.errExpected != errReceived {
t.Errorf("got unexpected error status %t", errReceived)
}
})
}
}