github.com/newrelic/newrelic-client-go@v1.1.0/pkg/errors/errors_test.go (about) 1 //go:build unit 2 // +build unit 3 4 package errors 5 6 import ( 7 "strings" 8 "testing" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestErrorNotFound(t *testing.T) { 14 t.Parallel() 15 16 var e NotFound 17 18 assert.Equal(t, "resource not found", e.Error()) 19 } 20 21 func TestErrorInvalidInput(t *testing.T) { 22 t.Parallel() 23 24 var e InvalidInput 25 26 assert.Equal(t, "invalid input error", e.Error()) 27 } 28 29 func TestErrorUnexpectedStatusCode(t *testing.T) { 30 t.Parallel() 31 32 e := NewUnexpectedStatusCode(99, "wat") 33 34 assert.Equal(t, "99 response returned: wat", e.Error()) 35 } 36 37 func TestErrorUnauthorized(t *testing.T) { 38 t.Parallel() 39 40 e := NewUnauthorizedError() 41 42 assert.Equal(t, 401, e.statusCode) 43 assert.True(t, strings.Contains(e.Error(), "Invalid credentials provided")) 44 }