MCPcopy Create free account
hub / github.com/go-task/task / TestWhenDirAttributeAndDirExistsItRunsInThatDir

Function TestWhenDirAttributeAndDirExistsItRunsInThatDir

task_test.go:1827–1846  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1825}
1826
1827func TestWhenDirAttributeAndDirExistsItRunsInThatDir(t *testing.T) {
1828 t.Parallel()
1829
1830 const expected = "exists"
1831 const dir = "testdata/dir/explicit_exists"
1832 var out bytes.Buffer
1833 e := task.NewExecutor(
1834 task.WithDir(dir),
1835 task.WithStdout(&out),
1836 task.WithStderr(&out),
1837 )
1838
1839 require.NoError(t, e.Setup())
1840 require.NoError(t, e.Run(t.Context(), &task.Call{Task: "whereami"}))
1841
1842 // Normalize path separators for cross-platform compatibility (Windows uses backslashes)
1843 normalized := normalizePathSeparators(out.String())
1844 got := strings.TrimSuffix(filepath.Base(normalized), "\n")
1845 assert.Equal(t, expected, got, "Mismatch in the working directory")
1846}
1847
1848func TestWhenDirAttributeItCreatesMissingAndRunsInThatDir(t *testing.T) {
1849 t.Parallel()

Callers

nothing calls this directly

Calls 4

SetupMethod · 0.95
RunMethod · 0.95
normalizePathSeparatorsFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…