forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
claimable_balance_request_test.go
53 lines (44 loc) · 1.36 KB
/
claimable_balance_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
46
47
48
49
50
51
52
53
package horizonclient
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestClaimableBalanceBuildUrl(t *testing.T) {
cbr := ClaimableBalanceRequest{
ID: "1235",
}
url, err := cbr.BuildURL()
assert.Equal(t, "claimable_balances/1235", url)
assert.NoError(t, err)
//if the ID is included, you cannot include another parameter
cbr = ClaimableBalanceRequest{
ID: "1235",
Claimant: "CLAIMANTADDRESS",
}
_, err = cbr.BuildURL()
assert.EqualError(t, err, "invalid request: too many parameters")
//if you have two parameters, and neither of them are ID, it must use both in the URL
cbr = ClaimableBalanceRequest{
Claimant: "CLAIMANTADDRESS",
Asset: "TEST:ISSUERADDRESS",
}
url, err = cbr.BuildURL()
assert.NoError(t, err)
assert.Equal(t, "claimable_balances?asset=TEST%3AISSUERADDRESS&claimant=CLAIMANTADDRESS", url)
//check limit
cbr = ClaimableBalanceRequest{
Claimant: "CLAIMANTADDRESS",
Asset: "TEST:ISSUERADDRESS",
Limit: 200,
}
url, err = cbr.BuildURL()
assert.NoError(t, err)
assert.Equal(t, "claimable_balances?asset=TEST%3AISSUERADDRESS&claimant=CLAIMANTADDRESS&limit=200", url)
cbr = ClaimableBalanceRequest{
Claimant: "CLAIMANTADDRESS",
Asset: "TEST:ISSUERADDRESS",
Limit: 201,
}
_, err = cbr.BuildURL()
assert.EqualError(t, err, "invalid request: limit 201 is greater than limit max of 200")
}