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

Function newWorkspaceToolTestServer

coderd/x/chatd/chatd_test.go:229–261  ·  view source on GitHub ↗
(
	t *testing.T,
	db database.Store,
	ps dbpubsub.Pubsub,
	agentID uuid.UUID,
	planContent string,
)

Source from the content-addressed store, hash-verified

227}
228
229func newWorkspaceToolTestServer(
230 t *testing.T,
231 db database.Store,
232 ps dbpubsub.Pubsub,
233 agentID uuid.UUID,
234 planContent string,
235) *chatd.Server {
236 t.Helper()
237
238 ctrl := gomock.NewController(t)
239 mockConn := agentconnmock.NewMockAgentConn(ctrl)
240 mockConn.EXPECT().SetExtraHeaders(gomock.Any()).AnyTimes()
241 mockConn.EXPECT().ContextConfig(gomock.Any()).
242 Return(workspacesdk.ContextConfigResponse{}, xerrors.New("not supported")).AnyTimes()
243 mockConn.EXPECT().ListMCPTools(gomock.Any()).
244 Return(workspacesdk.ListMCPToolsResponse{}, nil).AnyTimes()
245 mockConn.EXPECT().LS(gomock.Any(), gomock.Any(), gomock.Any()).
246 Return(workspacesdk.LSResponse{}, nil).AnyTimes()
247 mockConn.EXPECT().ReadFile(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
248 DoAndReturn(func(_ context.Context, path string, _, _ int64) (io.ReadCloser, string, error) {
249 if path == "/home/coder/PLAN.md" {
250 return io.NopCloser(strings.NewReader(planContent)), "", nil
251 }
252 return io.NopCloser(strings.NewReader("")), "", nil
253 }).AnyTimes()
254
255 return newActiveTestServer(t, db, ps, func(cfg *chatd.Config) {
256 cfg.AgentConn = func(_ context.Context, gotAgentID uuid.UUID) (workspacesdk.AgentConn, func(), error) {
257 require.Equal(t, agentID, gotAgentID)
258 return mockConn, func() {}, nil
259 }
260 })
261}
262
263func TestInterruptChatBroadcastsStatusAcrossInstances(t *testing.T) {
264 t.Parallel()

Callers 1

Calls 11

EXPECTMethod · 0.95
NewMockAgentConnFunction · 0.92
newActiveTestServerFunction · 0.85
HelperMethod · 0.65
SetExtraHeadersMethod · 0.65
ContextConfigMethod · 0.65
NewMethod · 0.65
ListMCPToolsMethod · 0.65
LSMethod · 0.65
ReadFileMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected