-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration_test.go
More file actions
101 lines (85 loc) · 2.37 KB
/
integration_test.go
File metadata and controls
101 lines (85 loc) · 2.37 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package form3
import (
"context"
"net/http"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
)
var (
testAccID string = uuid.New().String()
testOrgID string = uuid.New().String()
)
func createTestAccount(t *testing.T) *AccountData {
account := &AccountData{
Type: "accounts",
ID: testAccID,
OrganisationID: testOrgID,
Version: 0,
}
account.Attributes = &AccountAttributes{
Country: "FR",
BaseCurrency: "EUR",
BankID: "AF14",
BankIDCode: "GBDSC",
}
return account
}
func TestCreateAccountService(t *testing.T) {
service := LoadAccountsService(nil)
account := createTestAccount(t)
exptd := &AccountData{
Type: "accounts",
ID: testAccID,
OrganisationID: testOrgID,
}
exptd.Attributes = &AccountAttributes{
Country: "FR",
BaseCurrency: "EUR",
BankID: "AF14",
BankIDCode: "GBDSC",
}
ctx := context.Background()
result, resp, err := service.NewAccount(ctx, account)
assert.Nil(t, err)
if err != nil {
t.Error(err)
}
assert.NotNil(t, result)
assert.NotNil(t, resp)
assert.Equal(t, http.StatusCreated, resp.StatusCode)
assert.Equal(t, exptd.ID, result.ID)
assert.Equal(t, exptd.OrganisationID, result.OrganisationID)
service.DeleteByID(ctx, account.ID, account.Version)
}
func TestGetAccountByID(t *testing.T) {
service := LoadAccountsService(nil)
account := createTestAccount(t)
ctx := context.Background()
result, resp, err := service.NewAccount(ctx, account)
assert.Nil(t, err)
assert.NotNil(t, result)
assert.NotNil(t, resp)
resData, resResp, err := service.GetByID(ctx, account.ID)
assert.Nil(t, err)
assert.Equal(t, http.StatusOK, resResp.StatusCode)
assert.NotNil(t, resData)
assert.NotNil(t, resResp)
service.DeleteByID(ctx, account.ID, account.Version)
}
func TestDeleteByID(t *testing.T) {
service := LoadAccountsService(nil)
account := createTestAccount(t)
ctx := context.Background()
result, resp, err := service.NewAccount(ctx, account)
assert.Nil(t, err)
assert.NotNil(t, result)
assert.NotNil(t, resp)
resResp, err := service.DeleteByID(ctx, account.ID, account.Version)
assert.Nil(t, err)
assert.Equal(t, http.StatusNoContent, resResp.StatusCode)
assert.NotNil(t, resResp)
_, resGetResp, err := service.GetByID(ctx, account.ID)
assert.NotNil(t, err)
assert.Equal(t, http.StatusNotFound, resGetResp.StatusCode)
}