forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_request_test.go
42 lines (32 loc) · 1.18 KB
/
account_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
package horizonclient
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestAccountRequestBuildUrl(t *testing.T) {
ar := AccountRequest{}
_, err := ar.BuildURL()
// error case: No parameters
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "invalid request: no parameters")
}
ar.DataKey = "test"
_, err = ar.BuildURL()
// error case: few parameters for building account data endpoint
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "invalid request: too few parameters")
}
ar.DataKey = ""
ar.AccountID = "GCLWGQPMKXQSPF776IU33AH4PZNOOWNAWGGKVTBQMIC5IMKUNP3E6NVU"
endpoint, err := ar.BuildURL()
// It should return valid account details endpoint and no errors
require.NoError(t, err)
assert.Equal(t, "accounts/GCLWGQPMKXQSPF776IU33AH4PZNOOWNAWGGKVTBQMIC5IMKUNP3E6NVU", endpoint)
ar.DataKey = "test"
ar.AccountID = "GCLWGQPMKXQSPF776IU33AH4PZNOOWNAWGGKVTBQMIC5IMKUNP3E6NVU"
endpoint, err = ar.BuildURL()
// It should return valid account data endpoint and no errors
require.NoError(t, err)
assert.Equal(t, "accounts/GCLWGQPMKXQSPF776IU33AH4PZNOOWNAWGGKVTBQMIC5IMKUNP3E6NVU/data/test", endpoint)
}