diff --git a/api4/apitestlib.go b/api4/apitestlib.go index ef200bf2ff..537d8610c1 100644 --- a/api4/apitestlib.go +++ b/api4/apitestlib.go @@ -105,6 +105,12 @@ func Setup() *TestHelper { return th } +func StopServer() { + if app.Srv != nil { + app.StopServer() + } +} + func TearDown() { utils.DisableDebugLogForTest() diff --git a/api4/websocket_test.go b/api4/websocket_test.go index 1098f47595..5266e30a23 100644 --- a/api4/websocket_test.go +++ b/api4/websocket_test.go @@ -71,3 +71,12 @@ func TestWebSocket(t *testing.T) { } } } + +func TestZZWebSocketTearDown(t *testing.T) { + // *IMPORTANT* - Kind of hacky + // This should be the last function in any test file + // that calls Setup() + // Should be in the last file too sorted by name + time.Sleep(2 * time.Second) + StopServer() +}