Skip to content

Commit a57bd5d

Browse files
authored
Merge pull request #41 from Netflix-Skunkworks/fix-return-ordering
return package versions in ascending chronological order
2 parents bc61666 + 2064b8f commit a57bd5d

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Running the binary & tests requires standing up postgres:
1010
```sh
1111
export POSTGRES_USERNAME=postgres
1212
export POSTGRES_PASSWORD=postgres
13-
export POSTGRES_HOST=0.0.0.0
13+
export POSTGRES_HOST=127.0.0.1
1414
export POSTGRES_PORT=55432 # In case 5432 is in use already.
1515
export POSTGRES_DB=index
1616
docker run \

internal/db/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (d *DB) FetchRepoTags(ctx context.Context, since time.Time, limit int64) ([
5252
SELECT org_repo_name, tag_name, module_path, created
5353
FROM repo_tags
5454
WHERE created >= $1
55-
ORDER BY created DESC
55+
ORDER BY created ASC
5656
LIMIT $2;`
5757

5858
rows, err := d.db.QueryContext(ctx, query, since, limit)

internal/db/db_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ func TestFetchRepoTags(t *testing.T) {
1616
resetTables(t, sqlDB)
1717

1818
allTags := []*db.RepoTag{
19-
// Ordered by Created DESC, which is how we expect it returned.
20-
{OrgRepoName: "foo/gaz", TagName: "v0.0.1", ModulePath: "github.somecompany.net/foo/gaz", Created: time.Now().Add(time.Minute)},
21-
{OrgRepoName: "foo/bar", TagName: "v0.0.2", ModulePath: "github.somecompany.net/foo/bar", Created: time.Now().Add(time.Second)},
19+
// Ordered by Created ASC (ascending chronological order), which is how we expect it returned.
2220
{OrgRepoName: "foo/bar", TagName: "v0.0.1", ModulePath: "github.somecompany.net/foo/bar", Created: time.Now()},
21+
{OrgRepoName: "foo/bar", TagName: "v0.0.2", ModulePath: "github.somecompany.net/foo/bar", Created: time.Now().Add(time.Second)},
22+
{OrgRepoName: "foo/gaz", TagName: "v0.0.1", ModulePath: "github.somecompany.net/foo/gaz", Created: time.Now().Add(time.Minute)},
2323
}
2424
populateRepoTags(t, sqlDB, allTags)
2525

@@ -46,7 +46,7 @@ func TestFetchRepoTags(t *testing.T) {
4646
if err != nil {
4747
t.Fatal(err)
4848
}
49-
if diff := cmp.Diff(allTags[:1], gotTags, cmpopts.EquateApproxTime(time.Second)); diff != "" {
49+
if diff := cmp.Diff(allTags[2:], gotTags, cmpopts.EquateApproxTime(time.Second)); diff != "" {
5050
t.Errorf("FetchRepoTags: -want,+got: %s", diff)
5151
}
5252
}

0 commit comments

Comments
 (0)