Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| nil, | ||
| ) | ||
|
|
||
| require.NoError(t, err) |
There was a problem hiding this comment.
When the test puts the open-ended revision before the zero-duration revision, NewSubscriptionView reports subscription item history overlap. The test therefore fails at require.NoError, leaving the PostgreSQL-backed subscription test suite failing. The second EditRunning call may fail earlier if the repository returns those revisions in the same order.
Prompt To Fix With AI
This is a comment left during a code review.
Path: test/subscription/item_history_overlap_test.go
Line: 183
Comment:
**New test cannot pass**
When the test puts the open-ended revision before the zero-duration revision, `NewSubscriptionView` reports `subscription item history overlap`. The test therefore fails at `require.NoError`, leaving the PostgreSQL-backed subscription test suite failing. The second `EditRunning` call may fail earlier if the repository returns those revisions in the same order.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
@greptileai please regenerate the sequence diagram for this reproduction and add it to the PR summary. Show the two same-time API item replacements, the persisted original, zero-duration, and current revisions, the observed read order, and the subscription view rejecting the history as overlapping. |
When the same item on a running subscription is replaced twice at the same effective time through the API, the database stores the original revision, a zero-duration intermediate revision, and the current revision. That history is valid and remains relevant for an in-advance flat fee with proration disabled.
If the current revision is read before the zero-duration revision, the subscription view incorrectly treats the history as overlapping and rejects it. This pull request adds an API-driven, database-backed test that reproduces that failure.
The PR is not ready to merge because the new test still rejects the valid revision history it is intended to cover.
Fix with agent prompt
Summary
Adds a PostgreSQL-backed test for two same-time replacements of a subscription item and the resulting three-revision history.
Diagram
sequenceDiagram participant Client as API client participant Workflow as Subscription workflow participant DB as PostgreSQL participant View as Subscription view Client->>Workflow: Replace item at T (remove + add) Workflow->>DB: Persist original [start, T) and first replacement [T, ∞) Client->>Workflow: Replace same item again at T (remove + add) Workflow->>DB: Persist intermediate [T, T) and current [T, ∞) DB-->>View: Read original, current, intermediate View-->>Client: Reject history as overlappingReviews (2) · Last reviewed commit: "test: reproduce subscription item histor..."