Validate that the session has a max amount of events to hold
(t *testing.T)
| 119 | |
| 120 | // Validate that the session has a max amount of events to hold |
| 121 | func 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 | } |
nothing calls this directly
no test coverage detected