TestFileDescriptor() — gin Function Reference
Architecture documentation for the TestFileDescriptor() function in gin_integration_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD c327f60a_e247_8e40_612d_a2574d76f6ae["TestFileDescriptor()"] 076d326a_acfa_c808_1141_d1324fc6e43a["gin_integration_test.go"] c327f60a_e247_8e40_612d_a2574d76f6ae -->|defined in| 076d326a_acfa_c808_1141_d1324fc6e43a a9d0c6dd_554a_4f93_e325_111599f328a2["isWindows()"] c327f60a_e247_8e40_612d_a2574d76f6ae -->|calls| a9d0c6dd_554a_4f93_e325_111599f328a2 style c327f60a_e247_8e40_612d_a2574d76f6ae fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
gin_integration_test.go lines 298–337
func TestFileDescriptor(t *testing.T) {
router := New()
addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
require.NoError(t, err)
listener, err := net.ListenTCP("tcp", addr)
require.NoError(t, err)
socketFile, err := listener.File()
if isWindows() {
// not supported by windows, it is unimplemented now
require.Error(t, err)
} else {
require.NoError(t, err)
}
if socketFile == nil {
return
}
go func() {
router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
assert.NoError(t, router.RunFd(int(socketFile.Fd())))
}()
// 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("tcp", listener.Addr().String())
require.NoError(t, err)
fmt.Fprintf(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
Calls
Source
Frequently Asked Questions
What does TestFileDescriptor() do?
TestFileDescriptor() is a function in the gin codebase, defined in gin_integration_test.go.
Where is TestFileDescriptor() defined?
TestFileDescriptor() is defined in gin_integration_test.go at line 298.
What does TestFileDescriptor() call?
TestFileDescriptor() calls 1 function(s): isWindows.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free