TestUnixSocket() — gin Function Reference
Architecture documentation for the TestUnixSocket() function in gin_integration_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD e2bbe7a4_4dbc_1a26_68d2_271428167c24["TestUnixSocket()"] 076d326a_acfa_c808_1141_d1324fc6e43a["gin_integration_test.go"] e2bbe7a4_4dbc_1a26_68d2_271428167c24 -->|defined in| 076d326a_acfa_c808_1141_d1324fc6e43a style e2bbe7a4_4dbc_1a26_68d2_271428167c24 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
gin_integration_test.go lines 248–275
func TestUnixSocket(t *testing.T) {
router := New()
unixTestSocket := filepath.Join(os.TempDir(), "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(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", unixTestSocket)
require.NoError(t, err)
fmt.Fprint(c, "GET /example HTTP/1.0\r\n\r\n")
scanner := bufio.NewScanner(c)
var responseBuilder strings.Builder
for scanner.Scan() {
responseBuilder.WriteString(scanner.Text())
}
response := responseBuilder.String()
assert.Contains(t, response, "HTTP/1.0 200", "should get a 200")
assert.Contains(t, response, "it worked", "resp body should match")
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestUnixSocket() do?
TestUnixSocket() is a function in the gin codebase, defined in gin_integration_test.go.
Where is TestUnixSocket() defined?
TestUnixSocket() is defined in gin_integration_test.go at line 248.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free