newTestStore returns a Store backed by a temp cam.db with CAM_CONFIG_DIR and HOME isolated to temp directories so managed files and user-level install paths never touch the real home.
(t *testing.T)
| 11 | // HOME isolated to temp directories so managed files and user-level install |
| 12 | // paths never touch the real home. |
| 13 | func newTestStore(t *testing.T) *Store { |
| 14 | t.Helper() |
| 15 | cfg := t.TempDir() |
| 16 | home := t.TempDir() |
| 17 | t.Setenv("CAM_CONFIG_DIR", cfg) |
| 18 | t.Setenv("HOME", home) |
| 19 | t.Setenv("USERPROFILE", home) |
| 20 | s := New(filepath.Join(cfg, "cam.db")) |
| 21 | if err := s.Init(context.Background()); err != nil { |
| 22 | t.Fatalf("Init: %v", err) |
| 23 | } |
| 24 | return s |
| 25 | } |
| 26 | |
| 27 | func TestCRUDRoundTrip(t *testing.T) { |
| 28 | ctx := context.Background() |
no test coverage detected