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

Function TestResolveWorkspaceHome

coderd/x/chatd/chattool/planpath_test.go:18–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestResolveWorkspaceHome(t *testing.T) {
19 t.Parallel()
20
21 tests := []struct {
22 name string
23 resp workspacesdk.LSResponse
24 lsErr error
25 want string
26 wantErr bool
27 errMatch string
28 }{
29 {
30 name: "StandardLinuxHome",
31 resp: workspacesdk.LSResponse{AbsolutePathString: "/home/coder"},
32 want: "/home/coder",
33 },
34 {
35 name: "NonStandardHome",
36 resp: workspacesdk.LSResponse{AbsolutePathString: "/Users/dev"},
37 want: "/Users/dev",
38 },
39 {
40 name: "LSError",
41 lsErr: xerrors.New("list failed"),
42 wantErr: true,
43 errMatch: "list failed",
44 },
45 {
46 name: "EmptyAbsolutePathString",
47 resp: workspacesdk.LSResponse{AbsolutePathString: ""},
48 wantErr: true,
49 errMatch: "workspace home path is empty",
50 },
51 {
52 name: "WhitespaceOnlyAbsolutePathString",
53 resp: workspacesdk.LSResponse{AbsolutePathString: " \t\n "},
54 wantErr: true,
55 errMatch: "workspace home path is empty",
56 },
57 }
58
59 for _, testCase := range tests {
60 t.Run(testCase.name, func(t *testing.T) {
61 t.Parallel()
62
63 ctrl := gomock.NewController(t)
64 conn := agentconnmock.NewMockAgentConn(ctrl)
65
66 conn.EXPECT().LS(
67 gomock.Any(),
68 "",
69 workspacesdk.LSRequest{
70 Path: []string{},
71 Relativity: workspacesdk.LSRelativityHome,
72 },
73 ).Return(testCase.resp, testCase.lsErr)
74
75 got, err := chattool.ResolveWorkspaceHome(context.Background(), conn)

Callers

nothing calls this directly

Calls 9

EXPECTMethod · 0.95
NewMockAgentConnFunction · 0.92
ResolveWorkspaceHomeFunction · 0.92
NewMethod · 0.65
RunMethod · 0.65
LSMethod · 0.65
ErrorMethod · 0.45
EmptyMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected