moved actual go commands
This commit is contained in:
parent
c8032a3588
commit
fdb9d5f580
@ -7,6 +7,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
@ -28,10 +29,8 @@ import (
|
||||
)
|
||||
|
||||
func TestKeys(t *testing.T) {
|
||||
err := tests.InitServer()
|
||||
require.Nil(t, err)
|
||||
err := tests.StartServer()
|
||||
require.Nil(t, err)
|
||||
cmd := junkInit(t)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
// empty keys
|
||||
res, body := request(t, "GET", "/keys", nil)
|
||||
@ -94,15 +93,17 @@ func TestKeys(t *testing.T) {
|
||||
jsonStr = []byte(`{"password":"12345678901"}`)
|
||||
res, body = request(t, "DELETE", "/keys/test", jsonStr)
|
||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
}
|
||||
|
||||
db.Close()
|
||||
//XXX
|
||||
func junkInit(t *testing.T) *exec.Cmd {
|
||||
tests.TestInitBasecoin(t)
|
||||
return tests.StartServerForTest(t)
|
||||
}
|
||||
|
||||
func TestVersion(t *testing.T) {
|
||||
err := tests.InitServer()
|
||||
require.Nil(t, err)
|
||||
err := tests.StartServer()
|
||||
require.Nil(t, err)
|
||||
cmd := junkInit(t)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
// node info
|
||||
res, body := request(t, "GET", "/version", nil)
|
||||
@ -115,10 +116,8 @@ func TestVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNodeStatus(t *testing.T) {
|
||||
err := tests.InitServer()
|
||||
require.Nil(t, err)
|
||||
err := tests.StartServer()
|
||||
require.Nil(t, err)
|
||||
cmd := junkInit(t)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
// node info
|
||||
res, body := request(t, "GET", "/node_info", nil)
|
||||
@ -139,10 +138,8 @@ func TestNodeStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBlock(t *testing.T) {
|
||||
err := tests.InitServer()
|
||||
require.Nil(t, err)
|
||||
err := tests.StartServer()
|
||||
require.Nil(t, err)
|
||||
cmd := junkInit(t)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
// res, body := request(t, "GET", "/blocks/latest", nil)
|
||||
// require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
@ -173,10 +170,8 @@ func TestBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidators(t *testing.T) {
|
||||
err := tests.InitServer()
|
||||
require.Nil(t, err)
|
||||
err := tests.StartServer()
|
||||
require.Nil(t, err)
|
||||
cmd := junkInit(t)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
// res, body := request(t, "GET", "/validatorsets/latest", nil)
|
||||
// require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
@ -207,10 +202,8 @@ func TestValidators(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCoinSend(t *testing.T) {
|
||||
err := tests.InitServer()
|
||||
require.Nil(t, err)
|
||||
err := tests.StartServer()
|
||||
require.Nil(t, err)
|
||||
cmd := junkInit(t)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
// TODO make that account has coins
|
||||
kb := client.MockKeyBase()
|
||||
|
||||
@ -9,6 +9,8 @@ import (
|
||||
//"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// Tests assume the `basecoind` and `basecli` binaries
|
||||
@ -16,6 +18,7 @@ import (
|
||||
|
||||
// TODO remove test dirs if tests are successful
|
||||
|
||||
//nolint
|
||||
var (
|
||||
basecoind = "build/basecoind"
|
||||
basecli = "build/basecli"
|
||||
@ -42,7 +45,8 @@ func whereIsBasecli() string {
|
||||
return filepath.Join(gopath(), basecli)
|
||||
}
|
||||
|
||||
func TestInitBaseCoin(t *testing.T) {
|
||||
// Init Basecoin Test
|
||||
func TestInitBasecoin(t *testing.T) {
|
||||
Clean()
|
||||
|
||||
var err error
|
||||
@ -101,10 +105,6 @@ func makeKeys() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// these are in the original bash tests
|
||||
func TestBaseCliRecover(t *testing.T) {}
|
||||
func TestBaseCliShow(t *testing.T) {}
|
||||
|
||||
func _TestSendCoins(t *testing.T) {
|
||||
if err := StartServer(); err != nil {
|
||||
t.Error(err)
|
||||
@ -163,6 +163,17 @@ func StartServer() error {
|
||||
// see: https://stackoverflow.com/questions/11886531/terminating-a-process-started-with-os-exec-in-golang
|
||||
}
|
||||
|
||||
// expects TestInitBaseCoin to have been run
|
||||
func StartServerForTest(t *testing.T) *exec.Cmd {
|
||||
cmdName := whereIsBasecoind()
|
||||
cmdArgs := []string{"start", "--home", basecoindDir}
|
||||
cmd := exec.Command(cmdName, cmdArgs...)
|
||||
err := cmd.Start()
|
||||
require.Nil(t, err)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// clean the directories
|
||||
func Clean() {
|
||||
// ignore errors b/c the dirs may not yet exist
|
||||
os.Remove(basecoindDir)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user