diff options
author | Brian Cully <bjc@kublai.com> | 2015-07-10 19:46:13 +0000 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2015-07-10 19:46:13 +0000 |
commit | f8f30593d7df521d45fd85e1d90fb7b7fe54a980 (patch) | |
tree | adcfb9870d3c3454a7705d1afef3102195fd6fd8 | |
parent | f38c11939e83895411dfc0d1c79bca172c56f3fc (diff) | |
download | goctl-f8f30593d7df521d45fd85e1d90fb7b7fe54a980.tar.gz goctl-f8f30593d7df521d45fd85e1d90fb7b7fe54a980.zip |
Move tests for bultin commands to separate modules.
-rw-r--r-- | cmd_pid_test.go | 25 | ||||
-rw-r--r-- | cmd_ping_test.go | 23 | ||||
-rw-r--r-- | goctl_test.go | 20 |
3 files changed, 48 insertions, 20 deletions
diff --git a/cmd_pid_test.go b/cmd_pid_test.go new file mode 100644 index 0000000..681b116 --- /dev/null +++ b/cmd_pid_test.go @@ -0,0 +1,25 @@ +package goctl + +import ( + "strconv" + "testing" +) + +func TestPID(t *testing.T) { + gc := start(t) + defer gc.Stop() + + c := dial(t) + defer c.Close() + + buf := []byte("pid") + Write(c, buf) + + buf, err := Read(c) + if err != nil { + t.Fatalf("Couldn't read from socket: %s.", err) + } + if _, err = strconv.Atoi(string(buf)); err != nil { + t.Errorf("Requesting PID: got non-integer: '%s'.", string(buf)) + } +} diff --git a/cmd_ping_test.go b/cmd_ping_test.go new file mode 100644 index 0000000..89a08c7 --- /dev/null +++ b/cmd_ping_test.go @@ -0,0 +1,23 @@ +package goctl + +import "testing" + +func TestPing(t *testing.T) { + gc := start(t) + defer gc.Stop() + + c := dial(t) + defer c.Close() + + buf := []byte("ping") + Write(c, buf) + + buf, err := Read(c) + if err != nil { + t.Fatalf("Couldn't read from socket: %s.", err) + } + s := string(buf) + if s != "pong" { + t.Errorf("Sending ping: got '%s', expected 'pong'.", s) + } +} diff --git a/goctl_test.go b/goctl_test.go index 7e30f7e..dce75e7 100644 --- a/goctl_test.go +++ b/goctl_test.go @@ -55,26 +55,6 @@ func dial(t testing.TB) net.Conn { return c } -func TestPing(t *testing.T) { - gc := start(t) - defer gc.Stop() - - c := dial(t) - defer c.Close() - - buf := []byte("ping") - Write(c, buf) - - buf, err := Read(c) - if err != nil { - t.Fatalf("Couldn't read from socket: %s.", err) - } - s := string(buf) - if s != "pong" { - t.Errorf("Sending ping: got '%s', expected 'pong'.", s) - } -} - func TestAlreadyRunning(t *testing.T) { gc := start(t) defer gc.Stop() |