Make tests independent of host state
This commit is contained in:
@@ -253,9 +253,7 @@ func TestPromptDebugWriterKeepsWritesAnchoredToOpenedRoot(t *testing.T) {
|
||||
if err := os.Rename(root, anchoredRoot); err != nil {
|
||||
t.Fatalf("replace opened root: %v", err)
|
||||
}
|
||||
if err := os.Symlink(outside, root); err != nil {
|
||||
t.Skipf("symlink creation is unavailable: %v", err)
|
||||
}
|
||||
requireSymlink(t, outside, root)
|
||||
|
||||
ref := promptDebugRef()
|
||||
ref.RunID = "run-anchored"
|
||||
@@ -307,9 +305,7 @@ func TestPromptDebugWriterRejectsUnsafeRootsAndReferences(t *testing.T) {
|
||||
if err := os.Mkdir(target, debugDirectoryMode); err != nil {
|
||||
t.Fatalf("create root symlink target: %v", err)
|
||||
}
|
||||
if err := os.Symlink(target, link); err != nil {
|
||||
t.Fatalf("create root symlink: %v", err)
|
||||
}
|
||||
requireSymlink(t, target, link)
|
||||
if _, err := NewPromptDebugWriter(link); err == nil {
|
||||
t.Fatal("NewPromptDebugWriter(symlink) error = nil")
|
||||
}
|
||||
@@ -334,15 +330,20 @@ func TestPromptDebugWriterRejectsUnsafeRootsAndReferences(t *testing.T) {
|
||||
if err := os.Mkdir(outside, debugDirectoryMode); err != nil {
|
||||
t.Fatalf("create symlink component target: %v", err)
|
||||
}
|
||||
if err := os.Symlink(outside, filepath.Join(root, "debug", "daily")); err != nil {
|
||||
t.Fatalf("create symlink component: %v", err)
|
||||
}
|
||||
requireSymlink(t, outside, filepath.Join(root, "debug", "daily"))
|
||||
if _, err := writer.WritePreparation(promptDebugRef(), promptDebugPreparationFixture(), nil); err == nil {
|
||||
t.Fatal("WritePreparation(symlink component) error = nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func requireSymlink(t *testing.T, target string, link string) {
|
||||
t.Helper()
|
||||
if err := os.Symlink(target, link); err != nil {
|
||||
t.Skipf("symlink support is unavailable: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func promptDebugRef() PromptDebugRef {
|
||||
return PromptDebugRef{ReportID: report.Daily, ValidDate: "2026-05-29", RunID: "run-123"}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user