-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd: separated functions from cobra commands, some unittests. --passw…
…ord now belongs to account command, not its subcommands
- Loading branch information
1 parent
f10e442
commit 6bd18f7
Showing
2 changed files
with
180 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package cmd | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func TestCreate(t *testing.T) { | ||
password = "password" | ||
emptyCmd := cobra.Command{} | ||
|
||
dir, err := ioutil.TempDir("", "aecli") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer os.RemoveAll(dir) | ||
os.Chdir(dir) | ||
|
||
createFunc(&emptyCmd, []string{"test.json"}) | ||
} | ||
|
||
func TestAddress(t *testing.T) { | ||
password = "password" | ||
emptyCmd := cobra.Command{} | ||
|
||
dir, err := ioutil.TempDir("", "aecli") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer os.RemoveAll(dir) | ||
os.Chdir(dir) | ||
|
||
createFunc(&emptyCmd, []string{"test.json"}) | ||
addressFunc(&emptyCmd, []string{"test.json"}) | ||
} | ||
|
||
func TestSave(t *testing.T) { | ||
password = "password" | ||
emptyCmd := cobra.Command{} | ||
privateKey := "025528252ec5db7d77cd57e14ae7819b9205c84abe5eef8353f88330467048f458019537ef2e809fefe1f2513cda8c8aacc74fb30f8c1f8b32d99a16b7f539b8" | ||
dir, err := ioutil.TempDir("", "aecli") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer os.RemoveAll(dir) | ||
os.Chdir(dir) | ||
|
||
saveFunc(&emptyCmd, []string{"test.json", privateKey}) | ||
} | ||
|
||
func TestBalance(t *testing.T) { | ||
password = "password" | ||
emptyCmd := cobra.Command{} | ||
dir, err := ioutil.TempDir("", "aecli") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer os.RemoveAll(dir) | ||
os.Chdir(dir) | ||
|
||
createFunc(&emptyCmd, []string{"test.json"}) | ||
balanceFunc(&emptyCmd, []string{"test.json"}) | ||
} |