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

Function TestCloserStack_PushAfterClose

cli/ssh_internal_test.go:133–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

131}
132
133func TestCloserStack_PushAfterClose(t *testing.T) {
134 t.Parallel()
135 ctx := testutil.Context(t, testutil.WaitShort)
136 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug)
137 uut := newCloserStack(ctx, logger, quartz.NewMock(t))
138 closes := new([]*fakeCloser)
139 fc0 := &fakeCloser{closes: closes}
140 fc1 := &fakeCloser{closes: closes}
141
142 err := uut.push("fc0", fc0)
143 require.NoError(t, err)
144
145 exErr := xerrors.New("test")
146 uut.close(exErr)
147 require.Equal(t, []*fakeCloser{fc0}, *closes)
148
149 err = uut.push("fc1", fc1)
150 require.ErrorIs(t, err, exErr)
151 require.Equal(t, []*fakeCloser{fc1, fc0}, *closes, "should close fc1")
152}
153
154func TestCloserStack_CloseAfterContext(t *testing.T) {
155 t.Parallel()

Callers

nothing calls this directly

Calls 6

ContextFunction · 0.92
newCloserStackFunction · 0.85
pushMethod · 0.80
NewMethod · 0.65
closeMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected