-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain_test.go
More file actions
46 lines (43 loc) · 860 Bytes
/
main_test.go
File metadata and controls
46 lines (43 loc) · 860 Bytes
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
package main
import (
"errors"
"strings"
"testing"
)
func TestBuildCredentialErrorMessage(t *testing.T) {
tests := []struct {
name string
err error
wantChecks []string
}{
{
"decrypt_error",
errors.New("failed to decrypt credentials"),
[]string{
"Failed to load credentials",
"corrupted or encrypted",
"different SSH key",
"credentials.enc",
},
},
{
"generic_error",
errors.New("something went wrong"),
[]string{
"Failed to load credentials",
"something went wrong",
"check your configuration",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
msg := buildCredentialErrorMessage(tt.err)
for _, check := range tt.wantChecks {
if !strings.Contains(msg, check) {
t.Errorf("message missing %q\ngot: %s", check, msg)
}
}
})
}
}