diff --git a/amazon/validator.go b/amazon/validator.go index ea32c8f..0a3eb68 100644 --- a/amazon/validator.go +++ b/amazon/validator.go @@ -95,7 +95,7 @@ func (c *Client) Verify(ctx context.Context, userID string, receiptID string) (I resp, err := c.httpCli.Do(req) if err != nil { - return result, fmt.Errorf("%v", err) + return result, err } defer resp.Body.Close() diff --git a/amazon/validator_test.go b/amazon/validator_test.go index 4bc9629..1cc80cb 100644 --- a/amazon/validator_test.go +++ b/amazon/validator_test.go @@ -6,6 +6,7 @@ import ( "fmt" "net/http" "net/http/httptest" + "net/url" "os" "reflect" "testing" @@ -143,11 +144,17 @@ func TestVerifyTimeout(t *testing.T) { server, client := testTools(100, "timeout response") defer server.Close() - expected := errors.New("") ctx := context.Background() _, actual := client.Verify(ctx, "timeout", "timeout") - if !reflect.DeepEqual(reflect.TypeOf(actual), reflect.TypeOf(expected)) { - t.Errorf("got %v\nwant %v", actual, expected) + + // Actual should be a "request canceled" *url.Error + urlErr, ok := actual.(*url.Error) + if !ok { + t.Errorf("Expected *url.Error, got %T", actual) + } + + if !urlErr.Timeout() { + t.Errorf("got %v\nwant timeout", actual) } }