mirror of
https://github.com/google/gops.git
synced 2024-11-24 08:22:25 +02:00
48 lines
855 B
Go
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()
|
|
if portfile != "" {
|
|
t.Fatalf("got = %q; want empty portfile", portfile)
|
|
}
|
|
_, err = os.Stat(portfile)
|
|
if !os.IsNotExist(err) {
|
|
t.Fatalf("portfile = %q doesn't exist; err = %v", portfile, err)
|
|
}
|
|
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()
|
|
}
|