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

Function TestNewKeyFailoverTransport

aibridge/keypool/failover_test.go:28–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestNewKeyFailoverTransport(t *testing.T) {
29 t.Parallel()
30
31 pool, err := keypool.New([]string{"k0"}, quartz.NewMock(t))
32 require.NoError(t, err)
33
34 tests := []struct {
35 name string
36 // Constructor input.
37 config keypool.KeyFailoverConfig
38 // Whether the constructor returns inner unchanged.
39 expectSame bool
40 }{
41 {
42 // Pool is nil: failover is disabled, inner is returned unchanged.
43 name: "pool_nil_returns_inner",
44 config: keypool.KeyFailoverConfig{},
45 expectSame: true,
46 },
47 {
48 // Pool is set: inner is wrapped in a key-failover transport.
49 name: "pool_set_returns_wrapper",
50 config: keypool.KeyFailoverConfig{Pool: pool},
51 expectSame: false,
52 },
53 }
54
55 for _, tc := range tests {
56 t.Run(tc.name, func(t *testing.T) {
57 t.Parallel()
58
59 inner := &fakeRoundTripper{}
60 got := keypool.NewKeyFailoverTransport(inner, tc.config)
61
62 if tc.expectSame {
63 assert.Same(t, inner, got)
64 } else {
65 assert.NotSame(t, inner, got)
66 }
67 })
68 }
69}

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
NewKeyFailoverTransportFunction · 0.92
RunMethod · 0.65

Tested by

no test coverage detected