fix workspace output and cleanup uncertainty
This commit is contained in:
@@ -125,6 +125,34 @@ func TestWindowsStageHandleDeniesReadRenameDeleteAndHardlink(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteCanonicalExclusiveClassifiesDispositionFailureAsIndeterminate(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
path := filepath.Join(root, "candidate.yaml")
|
||||
if err := os.WriteFile(path, []byte("existing"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
oldDelete, oldClose := windowsDeleteHandle, windowsCloseStage
|
||||
t.Cleanup(func() { windowsDeleteHandle, windowsCloseStage = oldDelete, oldClose })
|
||||
windowsDeleteHandle = func(windows.Handle) error { return errors.New("injected disposition failure") }
|
||||
if err := writeCanonicalExclusive(path, []byte("candidate"), 0o600); !errors.Is(err, ErrIndeterminateFile) {
|
||||
t.Fatalf("disposition failure = %v, want ErrIndeterminateFile", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteCanonicalExclusiveClassifiesCloseFailureAsIndeterminate(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
path := filepath.Join(root, "candidate.yaml")
|
||||
if err := os.WriteFile(path, []byte("existing"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
oldDelete, oldClose := windowsDeleteHandle, windowsCloseStage
|
||||
t.Cleanup(func() { windowsDeleteHandle, windowsCloseStage = oldDelete, oldClose })
|
||||
windowsCloseStage = func(*os.File) error { return errors.New("injected close failure") }
|
||||
if err := writeCanonicalExclusive(path, []byte("candidate"), 0o600); !errors.Is(err, ErrIndeterminateFile) {
|
||||
t.Fatalf("close failure = %v, want ErrIndeterminateFile", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteCanonicalExclusiveRequiresRestrictiveMode(t *testing.T) {
|
||||
if err := writeCanonicalExclusive(`C:\\tmp\\thothctl-output.yaml`, []byte("x"), 0o640); err == nil {
|
||||
t.Fatal("accepted non-restrictive output mode")
|
||||
|
||||
Reference in New Issue
Block a user