From 8359bd764f4659fcd529a0e7c4e68362ffe4897e Mon Sep 17 00:00:00 2001 From: Sabrina Date: Tue, 28 Jan 2020 13:31:57 -0800 Subject: [PATCH] create mocks for playstore --- go.sum | 1 + playstore/mocks/mock_playstore.go | 158 ++++++++++++++++++++++++++++++ playstore/validator.go | 2 + 3 files changed, 161 insertions(+) create mode 100644 playstore/mocks/mock_playstore.go diff --git a/go.sum b/go.sum index 19d2eed..c28a786 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,7 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= diff --git a/playstore/mocks/mock_playstore.go b/playstore/mocks/mock_playstore.go new file mode 100644 index 0000000..b2e1bd6 --- /dev/null +++ b/playstore/mocks/mock_playstore.go @@ -0,0 +1,158 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/awa/go-iap/playstore (interfaces: IABProduct,IABSubscription) + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + gomock "github.com/golang/mock/gomock" + v3 "google.golang.org/api/androidpublisher/v3" + reflect "reflect" +) + +// MockIABProduct is a mock of IABProduct interface +type MockIABProduct struct { + ctrl *gomock.Controller + recorder *MockIABProductMockRecorder +} + +// MockIABProductMockRecorder is the mock recorder for MockIABProduct +type MockIABProductMockRecorder struct { + mock *MockIABProduct +} + +// NewMockIABProduct creates a new mock instance +func NewMockIABProduct(ctrl *gomock.Controller) *MockIABProduct { + mock := &MockIABProduct{ctrl: ctrl} + mock.recorder = &MockIABProductMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockIABProduct) EXPECT() *MockIABProductMockRecorder { + return m.recorder +} + +// AcknowledgeProduct mocks base method +func (m *MockIABProduct) AcknowledgeProduct(arg0 context.Context, arg1, arg2, arg3, arg4 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AcknowledgeProduct", arg0, arg1, arg2, arg3, arg4) + ret0, _ := ret[0].(error) + return ret0 +} + +// AcknowledgeProduct indicates an expected call of AcknowledgeProduct +func (mr *MockIABProductMockRecorder) AcknowledgeProduct(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcknowledgeProduct", reflect.TypeOf((*MockIABProduct)(nil).AcknowledgeProduct), arg0, arg1, arg2, arg3, arg4) +} + +// VerifyProduct mocks base method +func (m *MockIABProduct) VerifyProduct(arg0 context.Context, arg1, arg2, arg3 string) (*v3.ProductPurchase, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "VerifyProduct", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(*v3.ProductPurchase) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// VerifyProduct indicates an expected call of VerifyProduct +func (mr *MockIABProductMockRecorder) VerifyProduct(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyProduct", reflect.TypeOf((*MockIABProduct)(nil).VerifyProduct), arg0, arg1, arg2, arg3) +} + +// MockIABSubscription is a mock of IABSubscription interface +type MockIABSubscription struct { + ctrl *gomock.Controller + recorder *MockIABSubscriptionMockRecorder +} + +// MockIABSubscriptionMockRecorder is the mock recorder for MockIABSubscription +type MockIABSubscriptionMockRecorder struct { + mock *MockIABSubscription +} + +// NewMockIABSubscription creates a new mock instance +func NewMockIABSubscription(ctrl *gomock.Controller) *MockIABSubscription { + mock := &MockIABSubscription{ctrl: ctrl} + mock.recorder = &MockIABSubscriptionMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockIABSubscription) EXPECT() *MockIABSubscriptionMockRecorder { + return m.recorder +} + +// AcknowledgeSubscription mocks base method +func (m *MockIABSubscription) AcknowledgeSubscription(arg0 context.Context, arg1, arg2, arg3 string, arg4 *v3.SubscriptionPurchasesAcknowledgeRequest) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AcknowledgeSubscription", arg0, arg1, arg2, arg3, arg4) + ret0, _ := ret[0].(error) + return ret0 +} + +// AcknowledgeSubscription indicates an expected call of AcknowledgeSubscription +func (mr *MockIABSubscriptionMockRecorder) AcknowledgeSubscription(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcknowledgeSubscription", reflect.TypeOf((*MockIABSubscription)(nil).AcknowledgeSubscription), arg0, arg1, arg2, arg3, arg4) +} + +// CancelSubscription mocks base method +func (m *MockIABSubscription) CancelSubscription(arg0 context.Context, arg1, arg2, arg3 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CancelSubscription", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(error) + return ret0 +} + +// CancelSubscription indicates an expected call of CancelSubscription +func (mr *MockIABSubscriptionMockRecorder) CancelSubscription(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CancelSubscription", reflect.TypeOf((*MockIABSubscription)(nil).CancelSubscription), arg0, arg1, arg2, arg3) +} + +// RefundSubscription mocks base method +func (m *MockIABSubscription) RefundSubscription(arg0 context.Context, arg1, arg2, arg3 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RefundSubscription", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(error) + return ret0 +} + +// RefundSubscription indicates an expected call of RefundSubscription +func (mr *MockIABSubscriptionMockRecorder) RefundSubscription(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RefundSubscription", reflect.TypeOf((*MockIABSubscription)(nil).RefundSubscription), arg0, arg1, arg2, arg3) +} + +// RevokeSubscription mocks base method +func (m *MockIABSubscription) RevokeSubscription(arg0 context.Context, arg1, arg2, arg3 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RevokeSubscription", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(error) + return ret0 +} + +// RevokeSubscription indicates an expected call of RevokeSubscription +func (mr *MockIABSubscriptionMockRecorder) RevokeSubscription(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevokeSubscription", reflect.TypeOf((*MockIABSubscription)(nil).RevokeSubscription), arg0, arg1, arg2, arg3) +} + +// VerifySubscription mocks base method +func (m *MockIABSubscription) VerifySubscription(arg0 context.Context, arg1, arg2, arg3 string) (*v3.SubscriptionPurchase, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "VerifySubscription", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(*v3.SubscriptionPurchase) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// VerifySubscription indicates an expected call of VerifySubscription +func (mr *MockIABSubscriptionMockRecorder) VerifySubscription(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifySubscription", reflect.TypeOf((*MockIABSubscription)(nil).VerifySubscription), arg0, arg1, arg2, arg3) +} diff --git a/playstore/validator.go b/playstore/validator.go index 4642040..5a6e1ba 100644 --- a/playstore/validator.go +++ b/playstore/validator.go @@ -17,6 +17,8 @@ import ( androidpublisher "google.golang.org/api/androidpublisher/v3" ) +//go:generate mockgen -destination=mocks/mock_playstore.go -package=mocks github.com/awa/go-iap/playstore IABProduct,IABSubscription + // The IABProduct type is an interface for product service type IABProduct interface { VerifyProduct(context.Context, string, string, string) (*androidpublisher.ProductPurchase, error)