Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 11:16:11 +01:00

Fix unit test

This commit is contained in:
JakobDev 2024-11-14 19:18:43 +01:00
parent 27abd9fbb9
commit f8a1c40be7
No known key found for this signature in database
GPG key ID: 39DEF62C3ED6DC4C

View file

@ -93,32 +93,34 @@ func TestProjectsSort(t *testing.T) {
}{
{
sortType: "default",
wants: []int64{1, 3, 2, 6, 5, 4},
wants: []int64{1, 3, 2, 7, 6, 5, 4},
},
{
sortType: "oldest",
wants: []int64{4, 5, 6, 2, 3, 1},
wants: []int64{4, 5, 6, 7, 2, 3, 1},
},
{
sortType: "recentupdate",
wants: []int64{1, 3, 2, 6, 5, 4},
wants: []int64{1, 3, 2, 7, 6, 5, 4},
},
{
sortType: "leastupdate",
wants: []int64{4, 5, 6, 2, 3, 1},
wants: []int64{4, 5, 6, 7, 2, 3, 1},
},
}
for _, tt := range tests {
t.Run(tt.sortType, func(t *testing.T) {
projects, count, err := db.FindAndCount[Project](db.DefaultContext, SearchOptions{
OrderBy: GetSearchOrderByBySortType(tt.sortType),
})
require.NoError(t, err)
assert.EqualValues(t, int64(6), count)
if assert.Len(t, projects, 6) {
assert.EqualValues(t, int64(7), count)
if assert.Len(t, projects, 7) {
for i := range projects {
assert.EqualValues(t, tt.wants[i], projects[i].ID)
}
}
})
}
}