MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / commitmentJournal

Function commitmentJournal

internal/store/commitment_journal_test.go:25–55  ·  view source on GitHub ↗
(t *testing.T, s *Store, id string)

Source from the content-addressed store, hash-verified

23}
24
25func commitmentJournal(t *testing.T, s *Store, id string) []commitmentEntry {
26 t.Helper()
27 var workspaceID string
28 err := s.db.QueryRow(s.q(`SELECT workspace_id FROM schedule_changes WHERE schedule_id=? LIMIT 1`), id).Scan(&workspaceID)
29 if errors.Is(err, sql.ErrNoRows) {
30 return nil
31 }
32 if err != nil {
33 t.Fatal(err)
34 }
35 rows, err := s.scheduleChangesQ(s.db, workspaceID, id)
36 if err != nil {
37 t.Fatal(err)
38 }
39 var out []commitmentEntry
40 for _, row := range rows {
41 e := commitmentEntry{ID: row.ID, Type: row.ChangeType, Key: derefStr(row.OccurrenceKey), Role: derefStr(row.Role), Before: derefStr(row.BeforeJSON), After: derefStr(row.AfterJSON), Actor: row.Actor, Reason: row.Reason, Source: row.ReasonSource, Root: row.RootChangeID}
42 if row.ParentChangeID != nil {
43 e.Parent = sql.NullString{String: *row.ParentChangeID, Valid: true}
44 }
45 wantReason := ""
46 if e.Type == "move" {
47 wantReason = "Rescheduled"
48 }
49 if e.Source != "system" || e.Reason != wantReason || e.Root != e.ID || e.Parent.Valid {
50 t.Fatalf("journal provenance: %+v", e)
51 }
52 out = append(out, e)
53 }
54 return out
55}
56
57func commitmentSnapshot(t *testing.T, raw string) map[string]any {
58 t.Helper()

Calls 10

derefStrFunction · 0.85
appendFunction · 0.85
HelperMethod · 0.80
qMethod · 0.80
FatalMethod · 0.80
scheduleChangesQMethod · 0.80
FatalfMethod · 0.80
ScanMethod · 0.65
QueryRowMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected