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

@@ -45,6 +45,7 @@ func TestNamespaceCreate(t *testing.T) {
// from the source ns, provision a new global namespace "foo"
response, err := c.Setup(t).Namespaces().Create(namespace)
defer c.Close()
if err != nil {
t.Errorf("%#v should be nil.", err)
@@ -69,6 +70,7 @@ func TestNamespaceGet(t *testing.T) {
}
response, err := c.Setup(t).Namespaces().Get("foo")
defer c.Close()
if err != nil {
t.Errorf("%#v should be nil.", err)
@@ -96,6 +98,7 @@ func TestNamespaceList(t *testing.T) {
Response: simple.Response{StatusCode: 200, Body: namespaceList},
}
response, err := c.Setup(t).Namespaces().List(api.ListOptions{})
defer c.Close()
if err != nil {
t.Errorf("%#v should be nil.", err)
@@ -132,6 +135,7 @@ func TestNamespaceUpdate(t *testing.T) {
Response: simple.Response{StatusCode: 200, Body: requestNamespace},
}
receivedNamespace, err := c.Setup(t).Namespaces().Update(requestNamespace)
defer c.Close()
c.Validate(t, receivedNamespace, err)
}
@@ -157,6 +161,7 @@ func TestNamespaceFinalize(t *testing.T) {
Response: simple.Response{StatusCode: 200, Body: requestNamespace},
}
receivedNamespace, err := c.Setup(t).Namespaces().Finalize(requestNamespace)
defer c.Close()
c.Validate(t, receivedNamespace, err)
}
@@ -166,6 +171,7 @@ func TestNamespaceDelete(t *testing.T) {
Response: simple.Response{StatusCode: 200},
}
err := c.Setup(t).Namespaces().Delete("foo")
defer c.Close()
c.Validate(t, nil, err)
}
@@ -178,5 +184,6 @@ func TestNamespaceWatch(t *testing.T) {
Response: simple.Response{StatusCode: 200},
}
_, err := c.Setup(t).Namespaces().Watch(api.ListOptions{})
defer c.Close()
c.Validate(t, nil, err)
}