diff --git a/gin_integration_test.go b/gin_integration_test.go index f29d1fc1..5f508c70 100644 --- a/gin_integration_test.go +++ b/gin_integration_test.go @@ -146,15 +146,19 @@ func TestRunWithPort(t *testing.T) { func TestUnixSocket(t *testing.T) { router := New() + unixTestSocket := "/tmp/unix_unit_test" + + defer os.Remove(unixTestSocket) + go func() { router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") }) - assert.NoError(t, router.RunUnix("/tmp/unix_unit_test")) + assert.NoError(t, router.RunUnix(unixTestSocket)) }() // have to wait for the goroutine to start and run the server // otherwise the main thread will complete time.Sleep(5 * time.Millisecond) - c, err := net.Dial("unix", "/tmp/unix_unit_test") + c, err := net.Dial("unix", unixTestSocket) assert.NoError(t, err) fmt.Fprint(c, "GET /example HTTP/1.0\r\n\r\n")