| 65 | } |
| 66 | |
| 67 | func TestAppStateKeyValue(t *testing.T) { |
| 68 | ctx := context.Background() |
| 69 | store := New(filepath.Join(t.TempDir(), "cam.db")) |
| 70 | want := map[string]any{"sidebar": "wide"} |
| 71 | if err := store.SetState(ctx, "ui", want); err != nil { |
| 72 | t.Fatalf("SetState: %v", err) |
| 73 | } |
| 74 | var got map[string]any |
| 75 | ok, err := store.GetState(ctx, "ui", &got) |
| 76 | if err != nil { |
| 77 | t.Fatalf("GetState: %v", err) |
| 78 | } |
| 79 | if !ok || got["sidebar"] != "wide" { |
| 80 | t.Fatalf("state = ok:%v value:%+v", ok, got) |
| 81 | } |
| 82 | if _, err := os.Stat(store.Path()); err != nil { |
| 83 | t.Fatalf("db file missing: %v", err) |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // TestInitCreatesInstructionTablesWithoutLosingData verifies that opening a |
| 88 | // cam.db created before the instructions feature lands adds the new tables |