From 4427ca4a607802d2cd45268d83a180ef6aa0b5d4 Mon Sep 17 00:00:00 2001 From: Ronald Petty Date: Mon, 27 Apr 2020 18:36:04 -0700 Subject: [PATCH] Update gin_integration_test.go (#2341) * Update gin_integration_test.go TestUnixSocket fails if you run it twice in a row. This is due to the unix socket file persisting. Added defer to clean up. Whats unclear is the following test TestBadUnixSocket I suspect is just looking for cruft maybe from a prior test or defaults not working, I have not enough background to say. * Update gin_integration_test.go I believe there is some tab issue here, tried to manual overwrite it now. * Update gin_integration_test.go squash you dang spaces!!! --- gin_integration_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gin_integration_test.go b/gin_integration_test.go index f29d1fc..5f508c7 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")