-
Notifications
You must be signed in to change notification settings - Fork 17
/
subaccounts_test.go
68 lines (57 loc) · 1.59 KB
/
subaccounts_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
package goftx
import (
"os"
"testing"
"github.com/joho/godotenv"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestSubAccounts_CRUD(t *testing.T) {
_ = godotenv.Load()
ftx := New(
WithAuth(os.Getenv("FTX_KEY"), os.Getenv("FTX_SECRET")),
)
err := ftx.SetServerTimeDiff()
require.NoError(t, err)
nickname := "testSubAccount"
newNickname := "newTestSubAccount"
t.Run("getAll", func(t *testing.T) {
subs, err := ftx.SubAccounts.GetSubaccounts()
assert.NoError(t, err)
assert.NotNil(t, subs)
for _, sub := range subs {
require.True(t, sub.Nickname != nickname)
require.True(t, sub.Nickname != newNickname)
}
})
t.Run("create", func(t *testing.T) {
sub, err := ftx.SubAccounts.CreateSubaccount(nickname)
assert.NoError(t, err)
assert.NotNil(t, sub)
assert.Equal(t, nickname, sub.Nickname)
assert.True(t, sub.Deletable)
assert.True(t, sub.Editable)
})
t.Run("get_balances", func(t *testing.T) {
balances, err := ftx.SubAccounts.GetSubaccountBalances(nickname)
assert.NoError(t, err)
assert.NotNil(t, balances)
})
t.Run("update", func(t *testing.T) {
err = ftx.SubAccounts.ChangeSubaccount(nickname, newNickname)
assert.NoError(t, err)
})
t.Run("delete", func(t *testing.T) {
err = ftx.SubAccounts.DeleteSubaccount(newNickname)
assert.NoError(t, err)
})
t.Run("check", func(t *testing.T) {
subs, err := ftx.SubAccounts.GetSubaccounts()
assert.NoError(t, err)
assert.NotNil(t, subs)
for _, sub := range subs {
require.True(t, sub.Nickname != nickname)
require.True(t, sub.Nickname != newNickname)
}
})
}