GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( ade00f...013a6a )
by
unknown
01:57 queued 14s
created

mollie/wallets_test.go   A

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 74
dl 0
loc 101
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B mollie.TestMiscellaneousService_ApplePaymentSession 0 89 6
1
package mollie
2
3
import (
4
	"context"
5
	"fmt"
6
	"net/http"
7
	"testing"
8
9
	"github.com/VictorAvelar/mollie-api-go/v4/testdata"
10
	"github.com/stretchr/testify/assert"
11
)
12
13
func TestMiscellaneousService_ApplePaymentSession(t *testing.T) {
14
	setEnv()
15
	defer unsetEnv()
16
17
	type args struct {
18
		ctx       context.Context
19
		appleSess *ApplePaymentSessionRequest
20
	}
21
22
	cases := []struct {
23
		name    string
24
		args    args
25
		wantErr bool
26
		err     error
27
		pre     func()
28
		handler http.HandlerFunc
29
	}{
30
		{
31
			"get apple payment session works as expected.",
32
			args{
33
				context.Background(),
34
				&ApplePaymentSessionRequest{
35
					Domain: "https://example.com",
36
				},
37
			},
38
			false,
39
			nil,
40
			noPre,
41
			func(w http.ResponseWriter, r *http.Request) {
42
				testHeader(t, r, AuthHeader, "Bearer token_X12b31ggg23")
43
				testMethod(t, r, "POST")
44
45
				if _, ok := r.Header[AuthHeader]; !ok {
46
					w.WriteHeader(http.StatusUnauthorized)
47
				}
48
				_, _ = w.Write([]byte(testdata.ListMethodsResponse))
49
			},
50
		},
51
		{
52
			"get apple payment session, an error is returned from the server",
53
			args{
54
				context.Background(),
55
				nil,
56
			},
57
			true,
58
			fmt.Errorf("500 Internal Server Error: An internal server error occurred while processing your request."),
59
			noPre,
60
			errorHandler,
61
		},
62
		{
63
			"get apple payment session, an error occurs when parsing json",
64
			args{
65
				context.Background(),
66
				nil,
67
			},
68
			true,
69
			fmt.Errorf("invalid character 'h' looking for beginning of object key string"),
70
			noPre,
71
			encodingHandler,
72
		},
73
		{
74
			"get apple payment session, invalid url when building request",
75
			args{
76
				context.Background(),
77
				nil,
78
			},
79
			true,
80
			errBadBaseURL,
81
			crashSrv,
82
			errorHandler,
83
		},
84
	}
85
86
	for _, c := range cases {
87
		setup()
88
		defer teardown()
89
90
		t.Run(c.name, func(t *testing.T) {
91
			c.pre()
92
			tMux.HandleFunc("/v2/wallets/applepay/sessions", c.handler)
93
94
			res, m, err := tClient.Wallets.ApplePaymentSession(c.args.ctx, c.args.appleSess)
95
			if c.wantErr {
96
				assert.NotNil(t, err)
97
				assert.EqualError(t, err, c.err.Error())
98
			} else {
99
				assert.Nil(t, err)
100
				assert.IsType(t, &ApplePaymentSession{}, m)
101
				assert.IsType(t, &http.Response{}, res.Response)
102
			}
103
		})
104
	}
105
}
106