From c9721f9346db2e456b61fdc77684f3292464de17 Mon Sep 17 00:00:00 2001 From: Yingjie Run Date: Thu, 20 Jul 2017 18:32:47 +0800 Subject: [PATCH] add new errors test case --- appstore/validator_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/appstore/validator_test.go b/appstore/validator_test.go index 47d87af..2eed017 100644 --- a/appstore/validator_test.go +++ b/appstore/validator_test.go @@ -39,6 +39,13 @@ func TestHandleError(t *testing.T) { t.Errorf("got %v\nwant %v", actual, expected) } + // status 21004 + expected = errors.New("The shared secret you provided does not match the shared secret on file for your account.") + actual = HandleError(21004) + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %v\nwant %v", actual, expected) + } + // status 21005 expected = errors.New("The receipt server is not currently available.") actual = HandleError(21005) @@ -46,6 +53,13 @@ func TestHandleError(t *testing.T) { t.Errorf("got %v\nwant %v", actual, expected) } + // status 21006 + expected = errors.New("This receipt is valid but the subscription has expired. When this status code is returned to your server, the receipt data is also decoded and returned as part of the response.") + actual = HandleError(21006) + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %v\nwant %v", actual, expected) + } + // status 21007 expected = errors.New("This receipt is from the test environment, but it was sent to the production environment for verification. Send it to the test environment instead.") actual = HandleError(21007) @@ -60,6 +74,20 @@ func TestHandleError(t *testing.T) { t.Errorf("got %v\nwant %v", actual, expected) } + // status 21010 + expected = errors.New("This receipt could not be authorized. Treat this the same as if a purchase was never made.") + actual = HandleError(21010) + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %v\nwant %v", actual, expected) + } + + // status 21100 - 21199 + expected = errors.New("Internal data access error.") + actual = HandleError(21155) + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %v\nwant %v", actual, expected) + } + // status unknown expected = errors.New("An unknown error occurred") actual = HandleError(100)