github.com/koko1123/flow-go-1@v0.29.6/engine/access/rest/request/get_account_test.go (about) 1 package request 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func Test_GetAccount_InvalidParse(t *testing.T) { 11 var getAccount GetAccount 12 13 tests := []struct { 14 address string 15 height string 16 err string 17 }{ 18 {"", "", "invalid address"}, 19 {"f8d6e0586b0a20c7", "-1", "invalid height format"}, 20 } 21 22 for i, test := range tests { 23 err := getAccount.Parse(test.address, test.height) 24 assert.EqualError(t, err, test.err, fmt.Sprintf("test #%d failed", i)) 25 } 26 } 27 28 func Test_GetAccount_ValidParse(t *testing.T) { 29 var getAccount GetAccount 30 31 addr := "f8d6e0586b0a20c7" 32 err := getAccount.Parse(addr, "") 33 assert.NoError(t, err) 34 assert.Equal(t, getAccount.Address.String(), addr) 35 assert.Equal(t, getAccount.Height, SealedHeight) 36 37 err = getAccount.Parse(addr, "100") 38 assert.NoError(t, err) 39 assert.Equal(t, getAccount.Height, uint64(100)) 40 }