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

Function TestBasicTelemetryController_NotRecognised

tailnet/controllers_test.go:736–772  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

734}
735
736func TestBasicTelemetryController_NotRecognised(t *testing.T) {
737 t.Parallel()
738 ctx := testutil.Context(t, testutil.WaitShort)
739 logger := testutil.Logger(t)
740 ft := newFakeTelemetryClient()
741 uut := tailnet.NewBasicTelemetryController(logger)
742 uut.New(ft)
743
744 sendDone := make(chan struct{})
745 go func() {
746 defer close(sendDone)
747 uut.SendTelemetryEvent(&proto.TelemetryEvent{})
748 }()
749 // returning generic protocol error doesn't trigger unknown rpc logic
750 call := testutil.TryReceive(ctx, t, ft.calls)
751 testutil.RequireSend(ctx, t, call.errCh, drpc.ProtocolError.New("Protocol Error"))
752 testutil.TryReceive(ctx, t, sendDone)
753
754 sendDone = make(chan struct{})
755 go func() {
756 defer close(sendDone)
757 uut.SendTelemetryEvent(&proto.TelemetryEvent{})
758 }()
759 call = testutil.TryReceive(ctx, t, ft.calls)
760 // return the expected protocol error this time
761 testutil.RequireSend(ctx, t, call.errCh,
762 drpc.ProtocolError.New("unknown rpc: /coder.tailnet.v2.Tailnet/PostTelemetry"))
763 testutil.TryReceive(ctx, t, sendDone)
764
765 // now this returns immediately without a call, because unimplemented error disables calling
766 sendDone = make(chan struct{})
767 go func() {
768 defer close(sendDone)
769 uut.SendTelemetryEvent(&proto.TelemetryEvent{})
770 }()
771 testutil.TryReceive(ctx, t, sendDone)
772}
773
774type fakeTelemetryClient struct {
775 calls chan *fakeTelemetryCall

Callers

nothing calls this directly

Calls 9

NewMethod · 0.95
SendTelemetryEventMethod · 0.95
ContextFunction · 0.92
LoggerFunction · 0.92
TryReceiveFunction · 0.92
RequireSendFunction · 0.92
newFakeTelemetryClientFunction · 0.85
NewMethod · 0.65

Tested by

no test coverage detected