MCPcopy
hub / github.com/larksuite/cli / TestChdir

Function TestChdir

internal/cmdutil/testing.go:95–105  ·  view source on GitHub ↗

TestChdir changes the working directory to dir for the duration of the test. The original directory is restored via t.Cleanup. This enables tests to use LocalFileIO (which resolves relative paths under cwd) with temporary directories, keeping test artifacts out of the source tree. Not compatible wit

(t *testing.T, dir string)

Source from the content-addressed store, hash-verified

93// with temporary directories, keeping test artifacts out of the source tree.
94// Not compatible with t.Parallel() — os.Chdir is process-wide.
95func TestChdir(t *testing.T, dir string) {
96 t.Helper()
97 orig, err := vfs.Getwd()
98 if err != nil {
99 t.Fatalf("Getwd: %v", err)
100 }
101 if err := os.Chdir(dir); err != nil { //nolint:forbidigo // no vfs.Chdir yet; test-only, process-wide chdir
102 t.Fatalf("Chdir(%s): %v", dir, err)
103 }
104 t.Cleanup(func() { os.Chdir(orig) }) //nolint:forbidigo // matching restore
105}
106
107type testDefaultToken struct{}
108

Calls 2

GetwdFunction · 0.92
CleanupMethod · 0.65

Tested by

no test coverage detected