From 3544904708c4a0f1904b4c82b78381cb614e7817 Mon Sep 17 00:00:00 2001 From: George Leontiev Date: Tue, 30 Jan 2024 15:02:55 +0000 Subject: [PATCH 1/2] Align types for DeferSubscription method. --- playstore/validator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playstore/validator.go b/playstore/validator.go index 9afa460..3ae2493 100644 --- a/playstore/validator.go +++ b/playstore/validator.go @@ -34,7 +34,7 @@ type IABSubscription interface { CancelSubscription(context.Context, string, string, string) error RefundSubscription(context.Context, string, string, string) error RevokeSubscription(context.Context, string, string, string) error - DeferSubscription(context.Context, string, string, string, *androidpublisher.SubscriptionPurchasesDeferRequest) error + DeferSubscription(context.Context, string, string, string, *androidpublisher.SubscriptionPurchasesDeferRequest) (*androidpublisher.SubscriptionPurchasesDeferResponse, error) } // The IABSubscriptionV2 type is an interface for subscriptionV2 service From f50950ff5cfe408116de68880d3b8b54be69df51 Mon Sep 17 00:00:00 2001 From: George Leontiev Date: Tue, 30 Jan 2024 15:29:28 +0000 Subject: [PATCH 2/2] Add a test to avoid regression. --- playstore/validator_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/playstore/validator_test.go b/playstore/validator_test.go index 6b81e39..e7335e0 100644 --- a/playstore/validator_test.go +++ b/playstore/validator_test.go @@ -257,6 +257,26 @@ func TestRevokeSubscription(t *testing.T) { // TODO Normal scenario } +func TestDeferSubscription(t *testing.T) { + t.Parallel() + + ctx := context.Background() + client, _ := New(jsonKey) + deferralInfo := &androidpublisher.SubscriptionPurchasesDeferRequest{ + DeferralInfo: &androidpublisher.SubscriptionDeferralInfo{ + DesiredExpiryTimeMillis: 1234567890, + ExpectedExpiryTimeMillis: 1234567890, + }, + } + expectedStr := "googleapi: Error 404: No application was found for the given package name., applicationNotFound" + _, actual := client.DeferSubscription(ctx, "package", "productID", "purchaseToken", deferralInfo) + + if actual == nil || actual.Error() != expectedStr { + t.Errorf("got %v\nwant %v", actual, expectedStr) + } + // TODO Normal scenario +} + func TestGetSubscriptionOffer(t *testing.T) { t.Parallel() // Exception scenario