This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
payments_test.go
83 lines (73 loc) · 1.78 KB
/
payments_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2017 The Go-Mollie Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package mollie
import (
"testing"
)
func TestPaymentAddGet(t *testing.T) {
is := newPayments(&core{apiKey: "test_pQ2c9R3DDj2WbQdcaqFNxcjQQ6qSaU"})
p, err := is.New(PaymentData{
Amount: 100.99,
Description: "test descr",
RedirectURL: "http://www.google.com",
WebhookURL: "https://www.google.com/mollieapihook",
Method: "ideal",
Metadata: map[string]string{
"rikvdh": "mollie-api",
},
})
if err != nil {
t.Errorf("Error is not nil\n")
}
if len(p.ID) == 0 {
t.Errorf("ID must not be empty\n")
}
if p.Amount != 100.99 {
t.Errorf("Mollie may not change our amount! :O")
}
q, err := is.Get(p.ID)
if err != nil {
t.Errorf("Error is not nil\n")
}
if len(q.ID) == 0 {
t.Errorf("ID must not be empty\n")
}
if q.Amount != 100.99 {
t.Errorf("Mollie may not change our amount! :O")
}
}
func TestPaymentGetError(t *testing.T) {
is := newPayments(&core{apiKey: "test_pQ2c9R3DDj2WbQdcaqFNxcjQQ6qSaU"})
q, err := is.Get("foo_bar")
if err == nil {
t.Errorf("Error is not nil\n")
}
if q != nil {
t.Errorf("No payment may be retrieved\n")
}
}
func TestPaymentList(t *testing.T) {
is := newPayments(&core{apiKey: "test_pQ2c9R3DDj2WbQdcaqFNxcjQQ6qSaU"})
q, err := is.List(0, 2)
if err != nil {
t.Errorf("Error is not nil: %s\n", err)
}
if len(q) != 2 {
t.Errorf("Expect 2 issuers: %+v\n", q)
}
w, err := is.List(0, 1)
if err != nil {
t.Errorf("Error is not nil: %s\n", err)
}
if len(w) != 1 {
t.Errorf("Expect 1 issuer: %+v\n", w)
}
e, err := is.List(1, 1)
if err != nil {
t.Errorf("Error is not nil: %s\n", err)
}
if len(e) != 1 {
t.Errorf("ID must not be empty\n")
}
}