github.com/alloyzeus/go-azfl@v0.0.0-20231220071816-9740126a2d07/azerrs/descriptor_test.go (about) 1 package errors 2 3 import "testing" 4 5 func TestEmpty(t *testing.T) { 6 var err error = descWrap(nil, nil) 7 assert(t, "", err.Error()) 8 assert(t, nil, Unwrap(err)) 9 assert(t, nil, UnwrapDescriptor(err)) 10 } 11 12 func TestDescriptorOnly(t *testing.T) { 13 var err error = descWrap(ErrValueEmpty, nil) 14 assert(t, "empty", err.Error()) 15 assert(t, true, HasDescriptor(err, ErrValueEmpty)) 16 assert(t, false, HasDescriptor(err, ErrValueMalformed)) 17 assert(t, ErrValueEmpty, UnwrapDescriptor(err)) 18 assert(t, nil, Unwrap(err)) 19 } 20 21 func TestDetailsOnly(t *testing.T) { 22 var err error = descWrap(nil, Msg("unexpected condition")) 23 assert(t, "unexpected condition", err.Error()) 24 } 25 26 func TestDescWrapSimple(t *testing.T) { 27 var err error = descWrap(ErrAccessForbidden, Msg("insufficient permission")) 28 assert(t, "forbidden: insufficient permission", err.Error()) 29 }