github.com/puellanivis/breton@v0.2.16/lib/files/errors_test.go (about) 1 package files 2 3 import ( 4 "errors" 5 "os" 6 "testing" 7 ) 8 9 func TestInvalidURLErrors(t *testing.T) { 10 err := &invalidURLError{} 11 12 if !errors.Is(err, os.ErrInvalid) { 13 t.Error("errors.Is(invalidURLError, os.ErrInvalid) was false, wanted true") 14 } 15 if !errors.Is(err, ErrURLInvalid) { 16 t.Error("errors.Is(invalidURLError, ErrURLInvalid) was false, wanted true") 17 } 18 if !errors.Is(err, err) { 19 t.Errorf("errors.Is(invalidURLError, invalidURLError) was false, wanted true") 20 } 21 22 err2 := errors.Unwrap(err) 23 if err2 != ErrURLInvalid { 24 t.Errorf("errors.Unwrap(invalidURLError) was %#v, expected %#v", err2, ErrURLInvalid) 25 } 26 27 err3 := errors.Unwrap(err2) 28 if err3 != os.ErrInvalid { 29 t.Errorf("errors.Unwrap(ErrURLInvalid) was %#v, expected %#v", err3, os.ErrInvalid) 30 } 31 }