TestData-Factory [WIP]

This commit is contained in:
2022-12-09 00:13:10 +01:00
parent dd2f3baa0c
commit edfcdd1135
14 changed files with 1459 additions and 1022 deletions

View File

@@ -3,6 +3,10 @@ package google
import (
"context"
_ "embed"
"fmt"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
"strings"
"time"
)
type DummyGoogleAPIClient struct{}
@@ -12,5 +16,23 @@ func NewDummy() AndroidPublisherClient {
}
func (d DummyGoogleAPIClient) GetProductPurchase(ctx context.Context, packageName string, productId string, token string) (*ProductPurchase, error) {
if strings.HasPrefix(token, "PURCHASED:") {
return &ProductPurchase{
Kind: "",
PurchaseTimeMillis: fmt.Sprintf("%d", time.Date(2000, 1, 1, 12, 0, 0, 0, time.UTC).UnixMilli()),
PurchaseState: langext.Ptr(PurchaseStatePurchased),
ConsumptionState: ConsumptionStateConsumed,
DeveloperPayload: "{}",
OrderId: "000",
PurchaseType: nil,
AcknowledgementState: AcknowledgementStateAcknowledged,
PurchaseToken: nil,
ProductId: langext.Ptr("1234-5678"),
Quantity: nil,
ObfuscatedExternalAccountId: "000",
ObfuscatedExternalProfileId: "000",
RegionCode: "DE",
}, nil
}
return nil, nil // = purchase not found
}