diff options
| author | historia <[not public]> | 2026-10-05 20:00:02 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-05 20:00:02 -0400 |
| commit | 4bc1daaf259e0c19c5fe4a12ec8bc7f6e5a735c1 (patch) | |
| tree | f7ea1da2f88f37c44b937aaaf1fd12c722811147 /internal/admin/correct_audit_fixes_test.go | |
| parent | a5447965e7808d656a5e5d9326a9ca0231148f85 (diff) | |
| download | thehouseoficarus-4bc1daaf259e0c19c5fe4a12ec8bc7f6e5a735c1.tar.gz | |
feat: terminal talk action, typed pai gow poker phase
Diffstat (limited to 'internal/admin/correct_audit_fixes_test.go')
| -rw-r--r-- | internal/admin/correct_audit_fixes_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/admin/correct_audit_fixes_test.go b/internal/admin/correct_audit_fixes_test.go index d7b713e..282e943 100644 --- a/internal/admin/correct_audit_fixes_test.go +++ b/internal/admin/correct_audit_fixes_test.go @@ -89,3 +89,36 @@ func TestResolveDataPathRejectsSymlinkEscape(t *testing.T) { t.Fatalf("normal path rejected: %v", err) } } + +// Regression: an intentionally empty before-image must be restorable after a +// restart. The existence flag distinguishes it from a missing (failed-read) +// image, which both persist as "". +func TestUndoRestoresIntentionallyEmptyFile(t *testing.T) { + dir := t.TempDir() + path := filepath.Join(dir, "rooms", "1.yaml") + if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(path, []byte("id: 1\n"), 0644); err != nil { + t.Fatal(err) + } + us := NewUndoStack(dir) + us.Push(ChangeDesc{ + Description: "write to an originally empty file", + FilePath: path, + OldContent: []byte{}, // exists, but empty + NewContent: []byte("id: 1\n"), + }) + // Reload from disk to exercise the persistence round trip. + us2 := NewUndoStack(dir) + if ch := us2.Undo(); ch == nil { + t.Fatalf("undo of an empty-but-existing before-image was refused: %v", us2.LastError()) + } + data, err := os.ReadFile(path) + if err != nil { + t.Fatal(err) + } + if len(data) != 0 { + t.Fatalf("file not restored to empty: %q", data) + } +} |
