( ctx context.Context, t *testing.T, events <-chan codersdk.ChatStreamEvent, )
| 6146 | } |
| 6147 | |
| 6148 | func waitForTerminalChatStatusEvent( |
| 6149 | ctx context.Context, |
| 6150 | t *testing.T, |
| 6151 | events <-chan codersdk.ChatStreamEvent, |
| 6152 | ) codersdk.ChatStatus { |
| 6153 | t.Helper() |
| 6154 | |
| 6155 | var terminalStatus codersdk.ChatStatus |
| 6156 | testutil.Eventually(ctx, t, func(context.Context) bool { |
| 6157 | for { |
| 6158 | select { |
| 6159 | case event, ok := <-events: |
| 6160 | if !ok { |
| 6161 | return false |
| 6162 | } |
| 6163 | if event.Type != codersdk.ChatStreamEventTypeStatus || event.Status == nil { |
| 6164 | continue |
| 6165 | } |
| 6166 | if event.Status.Status == codersdk.ChatStatusWaiting || event.Status.Status == codersdk.ChatStatusError { |
| 6167 | terminalStatus = event.Status.Status |
| 6168 | return true |
| 6169 | } |
| 6170 | default: |
| 6171 | return false |
| 6172 | } |
| 6173 | } |
| 6174 | }, testutil.IntervalFast) |
| 6175 | |
| 6176 | return terminalStatus |
| 6177 | } |
| 6178 | |
| 6179 | func waitForTerminalChat( |
| 6180 | ctx context.Context, |
no test coverage detected