diff options
| author | historia <[not public]> | 2026-10-05 17:39:06 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-05 17:39:06 -0400 |
| commit | ec703a39738fefb60817f5659f76f8e683f8d301 (patch) | |
| tree | 00d1242d9f94bc2fec48331d8c02909be6b37f7a /internal/admin/correct_audit_fixes_test.go | |
| parent | 516fd29da423432ef6dfded21a984f1d15dcab1a (diff) | |
| download | thehouseoficarus-ec703a39738fefb60817f5659f76f8e683f8d301.tar.gz | |
fix: admin undo/redo failure, video poker cabinet ids, room ref behavior
Diffstat (limited to 'internal/admin/correct_audit_fixes_test.go')
| -rw-r--r-- | internal/admin/correct_audit_fixes_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/admin/correct_audit_fixes_test.go b/internal/admin/correct_audit_fixes_test.go index 60073f7..d97732d 100644 --- a/internal/admin/correct_audit_fixes_test.go +++ b/internal/admin/correct_audit_fixes_test.go @@ -49,3 +49,27 @@ func TestRestoreAccountSecretRefusesNonMappingBody(t *testing.T) { t.Fatalf("password hash not preserved: %s", out) } } + +// Regression: a failed undo returned a nil change exactly like an empty +// history, so the UI reported "Nothing to undo" for a real failure. +func TestUndoFailureIsReportedDistinctly(t *testing.T) { + dir := t.TempDir() + us := NewUndoStack(dir) + us.Push(ChangeDesc{ + Description: "edit with a missing before-image", + FilePath: filepath.Join(dir, "rooms", "1.yaml"), + OldContent: nil, + NewContent: []byte("id: 1\n"), + }) + if ch := us.Undo(); ch != nil { + t.Fatal("undo with a missing before-image unexpectedly succeeded") + } + if err := us.LastError(); err == nil { + t.Fatal("LastError = nil after a failed undo; the UI would report 'Nothing to undo'") + } + // A genuinely empty history is a clean nil change and nil error. + us2 := NewUndoStack(t.TempDir()) + if ch := us2.Undo(); ch != nil || us2.LastError() != nil { + t.Fatal("empty history must be a clean nil change and nil error") + } +} |
