github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/internal/multierr/multierr_test.go (about) 1 package multierr_test 2 3 import ( 4 "errors" 5 "testing" 6 7 "github.com/quickfeed/quickfeed/internal/multierr" 8 ) 9 10 func TestMultiErr(t *testing.T) { 11 nilErr := multierr.Join(nil) 12 if nilErr != nil { 13 t.Errorf("Join(nil) = %v, want <nil>", nilErr) 14 } 15 nilErr = multierr.Join(nil, nil, nil) 16 if nilErr != nil { 17 t.Errorf("Join(nil) = %v, want <nil>", nilErr) 18 } 19 20 wantErr1 := errors.New("a") 21 wantErr2 := errors.New("b") 22 err1 := multierr.Join(wantErr1) 23 if err1 == nil { 24 t.Errorf("Join(a) = %v, want %v", err1, wantErr1) 25 } 26 err2 := multierr.Join(wantErr1, wantErr2) 27 if err2 == nil { 28 t.Errorf("Join(a,b) = %v, want %v, %v", err2, wantErr1, wantErr2) 29 } 30 }