MCPcopy Create free account
hub / github.com/delinoio/oss / TestGetTaskStateByTaskKey

Function TestGetTaskStateByTaskKey

cmds/ttlc/internal/cache/sqlite_test.go:114–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

112}
113
114func 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
154func TestOpenResetsCacheOnSchemaVersionMismatch(t *testing.T) {
155 databasePath := filepath.Join(t.TempDir(), "cache", "cache.sqlite3")

Callers

nothing calls this directly

Calls 4

OpenFunction · 0.85
UpsertTaskMethod · 0.80
GetTaskStateByTaskKeyMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected