1
0
mirror of https://github.com/google/gops.git synced 2024-11-27 08:31:17 +02:00
gops/agent/agent_test.go
2016-12-20 12:48:15 -08:00

48 lines
855 B
Go

// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package agent
import (
"os"
"testing"
)
func TestListen(t *testing.T) {
err := Listen(nil)
if err != nil {
t.Fatal(err)
}
Close()
}
func TestAgentClose(t *testing.T) {
err := Listen(nil)
if err != nil {
t.Fatal(err)
}
Close()
_, err = os.Stat(portfile)
if !os.IsNotExist(err) {
t.Fatalf("portfile = %q doesn't exist; err = %v", portfile, err)
}
if portfile != "" {
t.Fatalf("got = %q; want empty portfile", portfile)
}
if listener != nil {
t.Fatalf("got listener listening at %v; want nil listener", listener.Addr())
}
}
func TestAgentListenMultipleClose(t *testing.T) {
err := Listen(nil)
if err != nil {
t.Fatal(err)
}
Close()
Close()
Close()
Close()
}