github.com/alloyzeus/go-azfl@v0.0.0-20231220071816-9740126a2d07/errors/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  	if err.Error() != "" {
     8  		t.Errorf(`err.Error() != "" -- %q`, err.Error())
     9  	}
    10  }
    11  
    12  func TestDescriptorOnly(t *testing.T) {
    13  	var err error = DescWrap(ErrValueEmpty, nil)
    14  	if err.Error() != "empty" {
    15  		t.Errorf(`err.Error() != "empty" -- %q`, err.Error())
    16  	}
    17  	if UnwrapDescriptor(err) != ErrValueEmpty {
    18  		t.Error("UnwrapDescriptor(err) != ErrValueEmpty")
    19  	}
    20  	if Unwrap(err) != nil {
    21  		t.Error("Unwrap(err) != nil")
    22  	}
    23  }
    24  
    25  func TestDetailsOnly(t *testing.T) {
    26  	var err error = DescWrap(nil, Msg("unexpected condition"))
    27  	if err.Error() != "unexpected condition" {
    28  		t.Errorf(`err.Error() != "unexpected condition" -- %q`, err.Error())
    29  	}
    30  }
    31  
    32  func TestDescWrapSimple(t *testing.T) {
    33  	var err error = DescWrap(ErrAccessForbidden, Msg("insufficient permission"))
    34  	assert(t, "forbidden: insufficient permission", err.Error())
    35  }