From e4fcd9de0aaa781abeb664b7b9935a82812b41cf Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Tue, 16 Jun 2015 15:34:23 -0700 Subject: [PATCH] Added server ping timer test --- server/ping_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 server/ping_test.go diff --git a/server/ping_test.go b/server/ping_test.go new file mode 100644 index 00000000..e956c602 --- /dev/null +++ b/server/ping_test.go @@ -0,0 +1,33 @@ +// Copyright 2015 Apcera Inc. All rights reserved. + +package server + +import ( + "fmt" + "testing" + "time" + + "github.com/apcera/nats" +) + +const PING_CLIENT_PORT = 11228 + +var DefaultPingOptions = Options{ + Host: "localhost", + Port: PING_CLIENT_PORT, + NoLog: true, + NoSigs: true, + PingInterval: 5 * time.Millisecond, +} + +func TestPing(t *testing.T) { + s := RunServer(&DefaultPingOptions) + defer s.Shutdown() + + nc, err := nats.Connect(fmt.Sprintf("nats://localhost:%d", PING_CLIENT_PORT)) + if err != nil { + t.Fatalf("Error creating client: %v\n", err) + } + defer nc.Close() + time.Sleep(10 * time.Millisecond) +}