Properly close test http servers in unversioned

If not, using `go test -count=n` would make them pile up and ultimately
get to the limit of open files:

	client_test.go:522: expected an error, got Get http://127.0.0.1:46070/api: dial tcp 127.0.0.1:46070: socket: too many open files

Steps to reproduce (no longer fails):

	godep go test -short -run '^$' -o test .
	./test -test.run '^TestGetSwaggerSchema' -test.count 100

Note that this might not fail if your `ulimit -n` is not low enough.
This commit is contained in:
Daniel Martí
2015-12-05 13:49:36 +01:00
parent 5505706891
commit 91fbff99dc
21 changed files with 137 additions and 2 deletions

View File

@@ -56,6 +56,7 @@ func TestEventSearch(t *testing.T) {
},
},
)
defer c.Close()
c.Validate(t, eventList, err)
}
@@ -89,6 +90,7 @@ func TestEventCreate(t *testing.T) {
}
response, err := c.Setup(t).Events(api.NamespaceDefault).Create(event)
defer c.Close()
if err != nil {
t.Fatalf("%v should be nil.", err)
@@ -129,6 +131,7 @@ func TestEventGet(t *testing.T) {
}
response, err := c.Setup(t).Events("other").Get("1")
defer c.Close()
if err != nil {
t.Fatalf("%v should be nil.", err)
@@ -170,6 +173,7 @@ func TestEventList(t *testing.T) {
Response: simple.Response{StatusCode: 200, Body: eventList},
}
response, err := c.Setup(t).Events(ns).List(api.ListOptions{})
defer c.Close()
if err != nil {
t.Errorf("%#v should be nil.", err)
@@ -196,5 +200,6 @@ func TestEventDelete(t *testing.T) {
Response: simple.Response{StatusCode: 200},
}
err := c.Setup(t).Events(ns).Delete("foo")
defer c.Close()
c.Validate(t, nil, err)
}