Skip to content

fix(test): unbreak CI for v_usdc_purchases-dependent tests#823

Merged
raymondjacobson merged 2 commits into
mainfrom
rj-fix-track-price-history-fk
May 18, 2026
Merged

fix(test): unbreak CI for v_usdc_purchases-dependent tests#823
raymondjacobson merged 2 commits into
mainfrom
rj-fix-track-price-history-fk

Conversation

@raymondjacobson
Copy link
Copy Markdown
Member

@raymondjacobson raymondjacobson commented May 18, 2026

Summary

Two related CI breakages on main from the recent v_usdc_purchases view migration. Both were pre-existing — surfaced when our PRs ran on main after the view changes landed.

1. track_price_history_blocknumber_fkey panics

TestV1UsersPurchases, TestV1UsersSales, TestV1UsersPurchasesDownload, TestV1UsersSalesDownload were all panicking with:

panic: ERROR: insert or update on table "track_price_history" violates foreign key constraint "track_price_history_blocknumber_fkey"

Each fixture hardcoded blocknumber: 100, but database.Seed only pre-inserts one block (number = 101). Just dropping the explicit blocknumber from each fixture row makes them inherit the baseRow default (101), and the view's lookup keys on block_timestamp anyway — so this is strictly fewer lines, no magic numbers.

2. TestGetNewBlasts/get_blasts_for_all_audiences missing blast_customer_track2

The fixture had track 2 owned by user 2 (the buyer). The new v_usdc_purchases view reports seller_user_id = current owner, so for that purchase seller=2. The customer_audience filter p.seller_user_id = blast.from_user_id then requires 2 = 1, never matches.

Fix: move track 2's ownership to user 1 (the artist) so the customer match works, and add a track 3 owned by user 2 with a matching remixes entry so user 2 still qualifies as a remixer of track 1.

Verification

Ran locally against docker compose DB:

go test ./api/ -run 'TestGetNewBlasts|TestV1UsersPurchases|TestV1UsersSales' -v
...
PASS
ok    api.audius.co/api    6.645s

15 tests pass including all five originally-broken ones.

TestV1UsersPurchases (and its sibling Sales / *Download tests) were
panicking with a track_price_history_blocknumber_fkey FK violation
because each fixture hardcoded blocknumber=100, but database.Seed
only ever pre-inserts one block (number=101).

The fixtures don't need to specify blocknumber at all — SeedTable
already merges the baseRows default for track_price_history (which
is 101), and the only field the view's lookup uses is
block_timestamp. Removing the explicit blocknumber eliminates the
duplicated magic number and makes the test fixtures match every
other fixture in the suite.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@raymondjacobson raymondjacobson force-pushed the rj-fix-track-price-history-fk branch from 7d81ec8 to 06d32e1 Compare May 18, 2026 19:08
TestGetNewBlasts/get_blasts_for_all_audiences was failing on main
because the fixture had track 2 owned by user 2 (the buyer), but
the v_usdc_purchases view computes seller_user_id as the current
content owner (not snapshotted at purchase time). With buyer ==
current owner == user 2, the customer_audience filter
(seller_user_id = blast.from_user_id) couldn't match the artist's
blast.

The fix moves track 2's ownership to user 1 (the artist) so the
customer match works, and adds a track 3 owned by user 2 with a
matching remixes entry so user 2 still qualifies as a remixer of
track 1. All TestGetNewBlasts subtests now pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@raymondjacobson raymondjacobson changed the title fix(test): seed track_price_history with the FK-valid blocknumber fix(test): unbreak CI for v_usdc_purchases-dependent tests May 18, 2026
@raymondjacobson raymondjacobson merged commit 8db1c4a into main May 18, 2026
5 checks passed
@raymondjacobson raymondjacobson deleted the rj-fix-track-price-history-fk branch May 18, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant