MCPcopy Index your code
hub / github.com/coder/coder / TestServer_CloseStopsForwarder

Function TestServer_CloseStopsForwarder

agent/boundarylogproxy/proxy_test.go:406–433  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

404}
405
406func TestServer_CloseStopsForwarder(t *testing.T) {
407 t.Parallel()
408
409 socketPath := filepath.Join(testutil.TempDirUnixSocket(t), "boundary.sock")
410 srv := boundarylogproxy.NewServer(testutil.Logger(t), socketPath, prometheus.NewRegistry())
411
412 err := srv.Start()
413 require.NoError(t, err)
414 t.Cleanup(func() { require.NoError(t, srv.Close()) })
415
416 reporter := &fakeReporter{}
417
418 forwarderCtx, forwarderCancel := context.WithCancel(context.Background())
419 forwarderDone := make(chan error, 1)
420 go func() {
421 forwarderDone <- srv.RunForwarder(forwarderCtx, reporter)
422 }()
423
424 // Cancel the forwarder context and verify it stops.
425 forwarderCancel()
426
427 select {
428 case err := <-forwarderDone:
429 require.ErrorIs(t, err, context.Canceled)
430 case <-time.After(testutil.WaitShort):
431 t.Fatal("forwarder did not stop")
432 }
433}
434
435func TestServer_InvalidProtobuf(t *testing.T) {
436 t.Parallel()

Callers

nothing calls this directly

Calls 8

StartMethod · 0.95
CloseMethod · 0.95
RunForwarderMethod · 0.95
TempDirUnixSocketFunction · 0.92
NewServerFunction · 0.92
LoggerFunction · 0.92
FatalMethod · 0.80
CleanupMethod · 0.65

Tested by

no test coverage detected