(t *testing.T)
| 112 | } |
| 113 | |
| 114 | func TestGetTaskStateByTaskKey(t *testing.T) { |
| 115 | databasePath := filepath.Join(t.TempDir(), "cache", "cache.sqlite3") |
| 116 | store, err := Open(databasePath) |
| 117 | if err != nil { |
| 118 | t.Fatalf("open store: %v", err) |
| 119 | } |
| 120 | t.Cleanup(func() { |
| 121 | _ = store.Close() |
| 122 | }) |
| 123 | |
| 124 | if err := store.UpsertTask(TaskRecord{ |
| 125 | TaskKey: "task-key-lookup", |
| 126 | Module: "build", |
| 127 | TaskID: "Build", |
| 128 | InputContentHash: "input-content-hash", |
| 129 | ParameterHash: "parameter-hash", |
| 130 | EnvironmentSnapshotHash: "environment-hash", |
| 131 | InputFingerprint: "input-hash", |
| 132 | Deps: []string{"dep-a"}, |
| 133 | Metadata: map[string]any{"module": "build"}, |
| 134 | UpdatedAt: time.Now().UTC(), |
| 135 | }); err != nil { |
| 136 | t.Fatalf("upsert task: %v", err) |
| 137 | } |
| 138 | |
| 139 | state, found, err := store.GetTaskStateByTaskKey("task-key-lookup") |
| 140 | if err != nil { |
| 141 | t.Fatalf("get task state by task key: %v", err) |
| 142 | } |
| 143 | if !found { |
| 144 | t.Fatal("expected task state to be found") |
| 145 | } |
| 146 | if state.TaskID != "Build" { |
| 147 | t.Fatalf("unexpected task id: %s", state.TaskID) |
| 148 | } |
| 149 | if state.TaskKey != "task-key-lookup" { |
| 150 | t.Fatalf("unexpected task key: %s", state.TaskKey) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | func TestOpenResetsCacheOnSchemaVersionMismatch(t *testing.T) { |
| 155 | databasePath := filepath.Join(t.TempDir(), "cache", "cache.sqlite3") |
nothing calls this directly
no test coverage detected