github.com/henvic/wedeploycli@v1.7.6-0.20200319005353-3630f582f284/exiterror/exiterror_test.go (about) 1 package exiterror 2 3 import ( 4 "testing" 5 ) 6 7 func TestNew(t *testing.T) { 8 var err error = New("this is an error", 67) 9 want := "this is an error" 10 code := 67 11 12 if err == nil { 13 t.Error("Expected error not to nil") 14 } 15 16 if err.Error() != want { 17 t.Errorf("Wanted error message to be %v, got %v instead", want, err.Error()) 18 } 19 20 e, ok := err.(Error) 21 22 if !ok { 23 t.Error("Expected error to be coerced to Error") 24 } 25 26 if e.Code() != code { 27 t.Errorf("Expected exit code to be %v, got %v instead", e.Code(), code) 28 } 29 }