MCPcopy
hub / github.com/golang-jwt/jwt / Test_joinErrors

Function Test_joinErrors

errors_test.go:9–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func Test_joinErrors(t *testing.T) {
10 type args struct {
11 errs []error
12 }
13 tests := []struct {
14 name string
15 args args
16 wantErrors []error
17 wantMessage string
18 }{
19 {
20 name: "multiple errors",
21 args: args{
22 errs: []error{ErrTokenNotValidYet, ErrTokenExpired},
23 },
24 wantErrors: []error{ErrTokenNotValidYet, ErrTokenExpired},
25 wantMessage: "token is not valid yet, token is expired",
26 },
27 }
28 for _, tt := range tests {
29 t.Run(tt.name, func(t *testing.T) {
30 err := joinErrors(tt.args.errs...)
31 for _, wantErr := range tt.wantErrors {
32 if !errors.Is(err, wantErr) {
33 t.Errorf("joinErrors() error = %v, does not contain %v", err, wantErr)
34 }
35 }
36
37 if err.Error() != tt.wantMessage {
38 t.Errorf("joinErrors() error.Error() = %v, wantMessage %v", err, tt.wantMessage)
39 }
40 })
41 }
42}
43
44func Test_newError(t *testing.T) {
45 type args struct {

Callers

nothing calls this directly

Calls 2

joinErrorsFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected