Pin historical partial invoice fixture to its original terms
1 file changed,
+7
−2
internal/console/billinginvoice_test.go+7 −2
CI passed — run details
diff --git a/internal/console/billinginvoice_test.go b/internal/console/billinginvoice_test.go| index 894592816..d5f9f30ae 100644 |
| --- a/internal/console/billinginvoice_test.go |
| +++ b/internal/console/billinginvoice_test.go |
| @@ -394,6 +394,11 @@ func invoiceFixtureNow() time.Time { return time.Date(2026, 10, 5, 12, 0, 0, 0, |
| // proves that), and the engine's provider path is exercised with the |
| // verification step substituted and nothing else. |
| func newInvoiceFixture(t *testing.T) *invoiceFixture { |
| + t.Helper() |
| + return newInvoiceFixtureWithTerms(t, plans.CurrentTermsVersion) |
| +} |
| + |
| +func newInvoiceFixtureWithTerms(t *testing.T, termsVersion string) *invoiceFixture { |
| t.Helper() |
| fx := newConsoleFixture(t) |
| acct, err := fx.st.AccountBySqid(fx.sqid) |
| @@ -407,7 +412,7 @@ func newInvoiceFixture(t *testing.T) *invoiceFixture { |
| t.Cleanup(ts.Close) |
| ix.installRuntime(t, ts.URL, fx.srv) |
| effective := time.Date(2026, 8, 10, 0, 0, 0, 0, time.UTC) |
| - if err := fx.st.applyBillingState(billingState{AccountID: acct.ID, Customer: "cus_hist", Subscription: "sub_hist", Status: "active", Plan: plans.PlanPersonal, Terms: plans.CurrentTermsVersion, Band: plans.BandA, Quantity: 1, PeriodStart: effective.Unix(), PeriodEnd: effective.AddDate(1, 0, 0).Unix()}, 0, "evt_hist", effective); err != nil { |
| + if err := fx.st.applyBillingState(billingState{AccountID: acct.ID, Customer: "cus_hist", Subscription: "sub_hist", Status: "active", Plan: plans.PlanPersonal, Terms: termsVersion, Band: plans.BandA, Quantity: 1, PeriodStart: effective.Unix(), PeriodEnd: effective.AddDate(1, 0, 0).Unix()}, 0, "evt_hist", effective); err != nil { |
| t.Fatal(err) |
| } |
| ix.state = usage.Statement{V: 1, Account: fx.sqid, Month: invoiceFixtureMonth, Meters: map[string]float64{usage.MeterInstanceHours: 1000}, DaysInMonth: 30, Closed: true, UpdatedAt: now.AddDate(0, 0, -1)} |
| @@ -1611,7 +1616,7 @@ func TestInvoiceEngineChecksOwnerImmediatelyBeforePost(t *testing.T) { |
| // against sixteen thirtieths of the allowance, and the fourteen days before |
| // the plan began are not billed. |
| func TestInvoiceEngineBillsAPartialFirstMonthOnItsPaidDays(t *testing.T) { |
| - ix := newInvoiceFixture(t) |
| + ix := newInvoiceFixtureWithTerms(t, "2026-09-07-v1") |
| if _, err := ix.st.db.Exec(`UPDATE billing_assignments SET effective_at=? WHERE account_id=?`, time.Date(2026, 9, 15, 0, 0, 0, 0, time.UTC).Unix(), ix.acct.ID); err != nil { |
| t.Fatal(err) |
| } |