phoenix/testutils/workingdir.go

16 lines
295 B
Go
Raw Normal View History

2024-03-25 16:09:55 +05:00
package testutils
import (
"os"
"path"
"runtime"
)
// Change the current directory to the project directory.
// Useful for tests that work with files.
func ResetWorkingDir() error {
_, filename, _, _ := runtime.Caller(0)
dir := path.Join(path.Dir(filename), "..")
return os.Chdir(dir)
}