summaryrefslogtreecommitdiffstats
path: root/ping_test.go
blob: 89a08c7374c684f592edf67ed14c05ecd75832d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)
	}
}