@@ -26,7 +26,7 @@ func TestAPIError_Error(t *testing.T) {
2626 StatusText : http .StatusText (http .StatusBadRequest ),
2727 Message : "there was an issue with the request" ,
2828 },
29- want : "Bad Request [400]: there was an issue with the request" ,
29+ want : "Bad Request: [400]: there was an issue with the request" ,
3030 },
3131 {
3232 name : "should return 5xx error" ,
@@ -35,7 +35,7 @@ func TestAPIError_Error(t *testing.T) {
3535 StatusText : http .StatusText (http .StatusInternalServerError ),
3636 Message : "there was an issue with the request" ,
3737 },
38- want : "Internal Server Error [500]: there was an issue with the request" ,
38+ want : "Internal Server Error: [500]: there was an issue with the request" ,
3939 },
4040 }
4141 for _ , tt := range tests {
@@ -79,3 +79,18 @@ func TestAPIError_errors_is(t *testing.T) {
7979 err := fn ()
8080 odize .AssertEqual (t , err .Error (), expected .Error ())
8181}
82+
83+ func TestAPIError_Unwrap (t * testing.T ) {
84+ var err * APIError
85+ expectedErr := APIError {
86+ StatusCode : http .StatusBadRequest ,
87+ StatusText : http .StatusText (http .StatusBadRequest ),
88+ Message : "some issue" ,
89+ }
90+ var testErr error = & expectedErr
91+ if errors .As (testErr , & err ) {
92+ odize .AssertEqual (t , err .Unwrap ().Error (), expectedErr .Error ())
93+ } else {
94+ t .Error ("non matching error" )
95+ }
96+ }
0 commit comments