MCPcopy Index your code
hub / github.com/docker/docker-agent / TestResolveWorkDir

Function TestResolveWorkDir

pkg/tools/builtin/shell/shell_test.go:250–275  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

248}
249
250func TestResolveWorkDir(t *testing.T) {
251 t.Parallel()
252
253 workingDir := "/configured/project"
254 h := &shellHandler{workingDir: workingDir}
255
256 tests := []struct {
257 name string
258 cwd string
259 expected string
260 }{
261 {name: "empty defaults to workingDir", cwd: "", expected: workingDir},
262 {name: "dot defaults to workingDir", cwd: ".", expected: workingDir},
263 {name: "absolute path unchanged", cwd: "/tmp/other", expected: "/tmp/other"},
264 {name: "relative path joined with workingDir", cwd: "src/pkg", expected: "/configured/project/src/pkg"},
265 {name: "relative with dot prefix", cwd: "./subdir", expected: "/configured/project/subdir"},
266 {name: "relative with parent traversal", cwd: "../sibling", expected: "/configured/sibling"},
267 }
268
269 for _, tt := range tests {
270 t.Run(tt.name, func(t *testing.T) {
271 t.Parallel()
272 assert.Equal(t, tt.expected, h.resolveWorkDir(tt.cwd))
273 })
274 }
275}
276
277func TestShellTool_RelativeCwdResolvesAgainstWorkingDir(t *testing.T) {
278 t.Parallel()

Callers

nothing calls this directly

Calls 2

resolveWorkDirMethod · 0.95
RunMethod · 0.65

Tested by

no test coverage detected