Refactor offline simulation tests so that they reliably set the env variable before ever starting the shell, since we need the env variable to also apply to presaving

This commit is contained in:
David Dworken
2023-10-22 11:28:41 -07:00
parent 53580d40e9
commit 9433bd6e94
2 changed files with 16 additions and 6 deletions

View File

@ -105,6 +105,8 @@ func BackupAndRestoreWithId(t testing.TB, id string) func() {
touchFile(path.Join(homedir, ".bash_history"))
touchFile(path.Join(homedir, ".zsh_history"))
touchFile(path.Join(homedir, ".local/share/fish/fish_history"))
restoreHishtoryOffline := BackupAndRestoreEnv("HISHTORY_SIMULATE_NETWORK_ERROR")
os.Setenv("HISHTORY_SIMULATE_NETWORK_ERROR", "")
return func() {
cmd := exec.Command("killall", "hishtory", "tmux")
stdout, err := cmd.Output()
@ -121,6 +123,7 @@ func BackupAndRestoreWithId(t testing.TB, id string) func() {
checkError(copy(getBackPath(file, id), file))
}
checkError(os.Chdir(initialWd))
restoreHishtoryOffline()
}
}