Skip to content

Commit a3f651b

Browse files
authored
Merge pull request #113 from jun06t/fix-test
Fix test
2 parents 3c88ce1 + 588d811 commit a3f651b

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

Makefile

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
2-
.PHONEY: all setup test cover
3-
1+
.PHONEY: all
42
all: setup cover
53

4+
.PHONEY: setup
65
setup:
7-
go get golang.org/x/tools/cmd/cover
8-
go get google.golang.org/appengine/urlfetch
9-
go get ./...
6+
go get golang.org/x/tools/cmd/cover
7+
go get google.golang.org/appengine/urlfetch
8+
go get ./...
109

10+
.PHONEY: test
1111
test:
12-
go test -v ./...
12+
go test -v ./...
1313

14+
.PHONEY: cover
1415
cover:
15-
go test -coverprofile=coverage.txt ./...
16+
go test -coverprofile=coverage.txt ./...
17+
18+
.PHONEY: generate
19+
generate:
20+
rm -rf ./appstore/mocks/*
21+
rm -rf ./playstore/mocks/*
22+
go generate ./...
File renamed without changes.

appstore/validator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111
)
1212

13-
//go:generate mockgen -destination=mocks/mock_appstore.go -package=mocks github.com/awa/go-iap/appstore IAPClient
13+
//go:generate mockgen -destination=mocks/appstore.go -package=mocks github.com/awa/go-iap/appstore IAPClient
1414

1515
const (
1616
// SandboxURL is the endpoint for sandbox environment.
File renamed without changes.

playstore/validator.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ import (
88
"crypto/x509"
99
"encoding/base64"
1010
"fmt"
11-
"google.golang.org/api/option"
1211
"net/http"
1312
"time"
1413

14+
"google.golang.org/api/option"
15+
1516
"golang.org/x/oauth2"
1617
"golang.org/x/oauth2/google"
1718
androidpublisher "google.golang.org/api/androidpublisher/v3"
1819
)
1920

20-
//go:generate mockgen -destination=mocks/mock_playstore.go -package=mocks github.com/awa/go-iap/playstore IABProduct,IABSubscription
21+
//go:generate mockgen -destination=mocks/playstore.go -package=mocks github.com/awa/go-iap/playstore IABProduct,IABSubscription
2122

2223
// The IABProduct type is an interface for product service
2324
type IABProduct interface {
@@ -46,7 +47,6 @@ func New(jsonKey []byte) (*Client, error) {
4647
c := &http.Client{Timeout: 10 * time.Second}
4748
ctx := context.WithValue(context.Background(), oauth2.HTTPClient, c)
4849

49-
5050
conf, err := google.JWTConfigFromJSON(jsonKey, androidpublisher.AndroidpublisherScope)
5151
if err != nil {
5252
return nil, err

playstore/validator_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestNew(t *testing.T) {
3535
t.Parallel()
3636

3737
// Exception scenario
38-
expected := "oauth2: cannot fetch token: 400 Bad Request\nResponse: {\n \"error\": \"invalid_grant\",\n \"error_description\": \"Invalid issuer: Not a service account.\"\n}"
38+
expected := "oauth2: cannot fetch token: 400 Bad Request\nResponse: {\"error\":\"invalid_grant\",\"error_description\":\"Invalid JWT: iss field missing.\"}"
3939

4040
_, err := New(dummyKey)
4141
if err == nil || err.Error() != expected {

0 commit comments

Comments
 (0)