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

Function TestWorkspaceBash

codersdk/toolsdk/bash_test.go:16–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestWorkspaceBash(t *testing.T) {
17 t.Parallel()
18 if runtime.GOOS == "windows" {
19 t.Skip("Skipping on Windows: Workspace MCP bash tools rely on a Unix-like shell (bash) and POSIX/SSH semantics. Use Linux/macOS or WSL for these tests.")
20 }
21
22 t.Run("ValidateArgs", func(t *testing.T) {
23 t.Parallel()
24
25 deps := toolsdk.Deps{}
26 ctx := context.Background()
27
28 // Test empty workspace name
29 args := toolsdk.WorkspaceBashArgs{
30 Workspace: "",
31 Command: "echo test",
32 }
33 _, err := toolsdk.WorkspaceBash.Handler(ctx, deps, args)
34 require.Error(t, err)
35 require.Contains(t, err.Error(), "workspace name cannot be empty")
36
37 // Test empty command
38 args = toolsdk.WorkspaceBashArgs{
39 Workspace: "test-workspace",
40 Command: "",
41 }
42 _, err = toolsdk.WorkspaceBash.Handler(ctx, deps, args)
43 require.Error(t, err)
44 require.Contains(t, err.Error(), "command cannot be empty")
45 })
46
47 t.Run("ErrorScenarios", func(t *testing.T) {
48 t.Parallel()
49
50 deps := toolsdk.Deps{}
51 ctx := context.Background()
52
53 // Test input validation errors (these should fail before client access)
54 t.Run("EmptyWorkspace", func(t *testing.T) {
55 args := toolsdk.WorkspaceBashArgs{
56 Workspace: "", // Empty workspace should be caught by validation
57 Command: "echo test",
58 }
59 _, err := toolsdk.WorkspaceBash.Handler(ctx, deps, args)
60 require.Error(t, err)
61 require.Contains(t, err.Error(), "workspace name cannot be empty")
62 })
63
64 t.Run("EmptyCommand", func(t *testing.T) {
65 args := toolsdk.WorkspaceBashArgs{
66 Workspace: "test-workspace",
67 Command: "", // Empty command should be caught by validation
68 }
69 _, err := toolsdk.WorkspaceBash.Handler(ctx, deps, args)
70 require.Error(t, err)
71 require.Contains(t, err.Error(), "command cannot be empty")
72 })
73 })

Callers

nothing calls this directly

Calls 8

SkipMethod · 0.80
NotEmptyMethod · 0.80
GenericMethod · 0.80
RunMethod · 0.65
HandlerMethod · 0.45
ErrorMethod · 0.45
ContainsMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected