Skip to content

Commit

Permalink
cmd: account balance unittest for when an account was found, and not …
Browse files Browse the repository at this point in the history
…found. Need to rework terminal.go to unwrap model.Error messages properly
  • Loading branch information
randomshinichi committed Feb 28, 2019
1 parent 042dd18 commit 5ba5fba
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion cmd/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestAccountSave(t *testing.T) {
}
}

func TestAccountBalance(t *testing.T) {
func TestAccountBalanceNotFound(t *testing.T) {
setCLIConfig()
password = "password"
emptyCmd := cobra.Command{}
Expand All @@ -80,6 +80,28 @@ func TestAccountBalance(t *testing.T) {
t.Error(err)
}
err = balanceFunc(&emptyCmd, []string{"test.json"})
if err == nil {
t.Error("Expected 'Account not found' error but got nil instead")
}
}

func TestAccountBalanceFound(t *testing.T) {
setCLIConfig()
password = "password"
privateKey := "e6a91d633c77cf5771329d3354b3bcef1bc5e032c43d70b6d35af923ce1eb74dcea7ade470c9f99d9d4e400880a86f1d49bb444b62f11a9ebb64bbcfeb73fef3"
emptyCmd := cobra.Command{}
dir, err := ioutil.TempDir("", "aecli")
if err != nil {
t.Error(err)
}
defer os.RemoveAll(dir)
os.Chdir(dir)

err = saveFunc(&emptyCmd, []string{"test.json", privateKey})
if err != nil {
t.Error(err)
}
err = balanceFunc(&emptyCmd, []string{"test.json"})
if err != nil {
t.Error(err)
}
Expand Down

0 comments on commit 5ba5fba

Please sign in to comment.