Skip to content

Commit aa82770

Browse files
Move latest track fixtures inline into test file
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bcb874e commit aa82770

3 files changed

Lines changed: 17 additions & 16 deletions

File tree

api/server_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func testAppWithFixtures(t *testing.T) *ApiServer {
9999
database.SeedTable(app.pool.Replicas[0], "reposts", testdata.RepostFixtures)
100100
database.SeedTable(app.pool.Replicas[0], "saves", testdata.SaveFixtures)
101101
database.SeedTable(app.pool.Replicas[0], "tracks", testdata.TrackFixtures)
102-
database.SeedTable(app.pool.Replicas[0], "tracks", testdata.LatestTrackFixtures)
103102
database.SeedTable(app.pool.Replicas[0], "track_trending_scores", testdata.TrackTrendingScoresFixtures)
104103
database.SeedTable(app.pool.Replicas[0], "trending_results", testdata.TrendingResultsFixtures)
105104
database.SeedTable(app.pool.Replicas[0], "track_routes", testdata.TrackRoutesFixtures)

api/testdata/latest_track_fixtures.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

api/v1_tracks_latest_test.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,25 @@ import (
44
"testing"
55

66
"api.audius.co/api/dbv1"
7+
"api.audius.co/database"
78
"api.audius.co/trashid"
89
"github.com/stretchr/testify/assert"
910
)
1011

11-
func TestGetLatest(t *testing.T) {
12+
func latestTestApp(t *testing.T) *ApiServer {
1213
app := testAppWithFixtures(t)
14+
database.SeedTable(app.pool.Replicas[0], "tracks", []map[string]any{
15+
{"track_id": 800, "genre": "LatestTestGenreA", "owner_id": 1, "title": "Latest Track Old", "is_unlisted": "f", "created_at": "2025-01-01 00:00:00"},
16+
{"track_id": 801, "genre": "LatestTestGenreA", "owner_id": 1, "title": "Latest Track Mid", "is_unlisted": "f", "created_at": "2025-02-01 00:00:00"},
17+
{"track_id": 802, "genre": "LatestTestGenreC", "owner_id": 1, "title": "Latest Track New", "is_unlisted": "f", "created_at": "2025-03-01 00:00:00"},
18+
{"track_id": 803, "genre": "LatestTestGenreB", "owner_id": 1, "title": "Latest Track Visible", "is_unlisted": "f", "created_at": "2025-02-15 00:00:00"},
19+
{"track_id": 804, "genre": "LatestTestGenreB", "owner_id": 1, "title": "Latest Track Hidden", "is_unlisted": "t", "created_at": "2025-02-20 00:00:00"},
20+
})
21+
return app
22+
}
23+
24+
func TestGetLatest(t *testing.T) {
25+
app := latestTestApp(t)
1326
var resp struct {
1427
Data []dbv1.Track
1528
}
@@ -19,7 +32,7 @@ func TestGetLatest(t *testing.T) {
1932
}
2033

2134
func TestGetLatestWithGenre(t *testing.T) {
22-
app := testAppWithFixtures(t)
35+
app := latestTestApp(t)
2336
var resp struct {
2437
Data []dbv1.Track
2538
}
@@ -34,7 +47,7 @@ func TestGetLatestWithGenre(t *testing.T) {
3447
}
3548

3649
func TestGetLatestWithLimitOffset(t *testing.T) {
37-
app := testAppWithFixtures(t)
50+
app := latestTestApp(t)
3851
var resp struct {
3952
Data []dbv1.Track
4053
}
@@ -50,7 +63,7 @@ func TestGetLatestWithLimitOffset(t *testing.T) {
5063
}
5164

5265
func TestGetLatestExcludesUnlisted(t *testing.T) {
53-
app := testAppWithFixtures(t)
66+
app := latestTestApp(t)
5467
var resp struct {
5568
Data []dbv1.Track
5669
}

0 commit comments

Comments
 (0)