(t *testing.T, s *Store, id string)
| 23 | } |
| 24 | |
| 25 | func 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 | |
| 57 | func commitmentSnapshot(t *testing.T, raw string) map[string]any { |
| 58 | t.Helper() |
no test coverage detected