MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / TestSession_InsertOverflow

Function TestSession_InsertOverflow

management/session_test.go:121–147  ·  view source on GitHub ↗

Validate that the session has a max amount of events to hold

(t *testing.T)

Source from the content-addressed store, hash-verified

119
120// Validate that the session has a max amount of events to hold
121func TestSession_InsertOverflow(t *testing.T) {
122 _, cancel := context.WithCancel(context.Background())
123 defer cancel()
124 session := newSession(1, actor{}, cancel)
125 log := Log{
126 Time: time.Now().UTC().Format(time.RFC3339),
127 Event: HTTP,
128 Level: Info,
129 Message: "test",
130 }
131 // Insert 2 but only max channel size for 1
132 session.Insert(&log)
133 session.Insert(&log)
134 select {
135 case <-session.listener:
136 // pass
137 default:
138 require.Fail(t, "expected one log event")
139 }
140 // Second dequeue should fail
141 select {
142 case <-session.listener:
143 require.Fail(t, "expected no more remaining log events")
144 default:
145 // pass
146 }
147}

Callers

nothing calls this directly

Calls 2

newSessionFunction · 0.85
InsertMethod · 0.80

Tested by

no test coverage detected