Test_Ctx_SendStreamWriter_Interrupted() — fiber Function Reference
Architecture documentation for the Test_Ctx_SendStreamWriter_Interrupted() function in ctx_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD f25dbb9c_b905_e0f8_9cce_af95312a372e["Test_Ctx_SendStreamWriter_Interrupted()"] 7b3d4933_5ae3_f84d_ff6d_0cb34e268026["ctx_test.go"] f25dbb9c_b905_e0f8_9cce_af95312a372e -->|defined in| 7b3d4933_5ae3_f84d_ff6d_0cb34e268026 style f25dbb9c_b905_e0f8_9cce_af95312a372e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
ctx_test.go lines 7245–7283
func Test_Ctx_SendStreamWriter_Interrupted(t *testing.T) {
t.Parallel()
app := New()
var flushed atomic.Int32
var flushErrLine atomic.Int32
app.Get("/", func(c Ctx) error {
return c.SendStreamWriter(func(w *bufio.Writer) {
for lineNum := 1; lineNum <= 5; lineNum++ {
fmt.Fprintf(w, "Line %d\n", lineNum)
if err := w.Flush(); err != nil {
flushErrLine.Store(int32(lineNum)) //nolint:gosec // G115 - lineNum is 1-5, fits int32
return
}
if lineNum <= 3 {
flushed.Add(1)
}
if lineNum == 3 {
time.Sleep(500 * time.Millisecond)
}
}
})
})
req := httptest.NewRequest(MethodGet, "/", http.NoBody)
testConfig := TestConfig{
// allow enough time for three lines to flush before
// the test connection is closed but stop before the
// fourth line is sent
Timeout: 200 * time.Millisecond,
FailOnTimeout: true, // Changed to true to test interrupted behavior
}
resp, err := app.Test(req, testConfig)
// With FailOnTimeout: true, we should get a timeout error
require.ErrorIs(t, err, os.ErrDeadlineExceeded)
require.Nil(t, resp)
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Ctx_SendStreamWriter_Interrupted() do?
Test_Ctx_SendStreamWriter_Interrupted() is a function in the fiber codebase, defined in ctx_test.go.
Where is Test_Ctx_SendStreamWriter_Interrupted() defined?
Test_Ctx_SendStreamWriter_Interrupted() is defined in ctx_test.go at line 7245.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free