forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
accounts_request_test.go
45 lines (37 loc) · 1.17 KB
/
accounts_request_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
package horizonclient
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestAccountsRequestBuildUrl(t *testing.T) {
// error case: No parameters
_, err := AccountsRequest{}.BuildURL()
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "invalid request: no parameters")
}
// error case: too many parameters
_, err = AccountsRequest{
Signer: "signer",
Asset: "asset",
}.BuildURL()
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "invalid request: too many parameters")
}
// signer
endpoint, err := AccountsRequest{Signer: "abcdef"}.BuildURL()
require.NoError(t, err)
assert.Equal(t, "accounts?signer=abcdef", endpoint)
// asset
endpoint, err = AccountsRequest{Asset: "abcdef"}.BuildURL()
require.NoError(t, err)
assert.Equal(t, "accounts?asset=abcdef", endpoint)
// sponsor
endpoint, err = AccountsRequest{Sponsor: "abcdef"}.BuildURL()
require.NoError(t, err)
assert.Equal(t, "accounts?sponsor=abcdef", endpoint)
// liquidity_pool
endpoint, err = AccountsRequest{LiquidityPool: "abcdef"}.BuildURL()
require.NoError(t, err)
assert.Equal(t, "accounts?liquidity_pool=abcdef", endpoint)
}