MCPcopy Create free account
hub / github.com/compozy/agh / insertMemoryObservabilityEvent

Function insertMemoryObservabilityEvent

internal/memory/observability_test.go:217–253  ·  view source on GitHub ↗
(
	ctx context.Context,
	t *testing.T,
	catalog *catalog,
	op string,
	scope string,
	workspaceID string,
	agentName string,
	summary string,
	timestamp time.Time,
)

Source from the content-addressed store, hash-verified

215}
216
217func insertMemoryObservabilityEvent(
218 ctx context.Context,
219 t *testing.T,
220 catalog *catalog,
221 op string,
222 scope string,
223 workspaceID string,
224 agentName string,
225 summary string,
226 timestamp time.Time,
227) {
228 t.Helper()
229
230 db, err := catalog.ensureDB(ctx)
231 if err != nil {
232 t.Fatalf("catalog.ensureDB() error = %v", err)
233 }
234 metadata, err := json.Marshal(map[string]string{memoryEventMetadataSummaryKey: summary})
235 if err != nil {
236 t.Fatalf("json.Marshal(metadata) error = %v", err)
237 }
238 if _, err := db.ExecContext(
239 ctx,
240 `INSERT INTO memory_events (
241 op, scope, agent_name, workspace_id, actor_kind, metadata, ts_ms
242 ) VALUES (?, ?, ?, ?, ?, ?, ?)`,
243 op,
244 nullStringForEmpty(scope),
245 agentName,
246 nullStringForEmpty(workspaceID),
247 "system",
248 string(metadata),
249 timeToUnixMillis(timestamp),
250 ); err != nil {
251 t.Fatalf("insert memory event error = %v", err)
252 }
253}

Callers 2

TestStoreHealthStatsFunction · 0.85

Calls 4

nullStringForEmptyFunction · 0.85
timeToUnixMillisFunction · 0.85
ensureDBMethod · 0.80
ExecContextMethod · 0.65

Tested by

no test coverage detected