-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_test.go
45 lines (43 loc) · 854 Bytes
/
error_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
package different
import (
"errors"
"testing"
)
func TestGenerateError(t *testing.T) {
type args struct {
err error
flag string
args []string
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "When_errorWrapUsingFlagReturnSuccess_Expect_Success",
args: args{
err: errors.New("some error"),
flag: "tes",
args: []string{"unmarshal"},
},
wantErr: true,
},
{
name: "When_errParamNilReturnSuccess_Expect_Success",
args: args{
err: nil,
flag: "tes",
args: []string{"unmarshal"},
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := generateError(tt.args.err, tt.args.flag, tt.args.args...); (err != nil) != tt.wantErr {
t.Errorf("GenerateError() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}