Make software list not flaky, hopefully (#2387)

This commit is contained in:
Tomas Touceda 2021-10-05 18:26:02 -03:00 committed by GitHub
parent d7cbcdfb40
commit 02b2c64b89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -425,7 +425,7 @@ func testSoftwareList(t *testing.T, ds *Datastore) {
})
t.Run("limits the results", func(t *testing.T) {
software, err := ds.ListSoftware(context.Background(), nil, fleet.ListOptions{PerPage: 1})
software, err := ds.ListSoftware(context.Background(), nil, fleet.ListOptions{PerPage: 1, OrderKey: "version"})
require.NoError(t, err)
require.Len(t, software, 1)
@ -434,11 +434,11 @@ func testSoftwareList(t *testing.T, ds *Datastore) {
})
t.Run("paginates", func(t *testing.T) {
software, err := ds.ListSoftware(context.Background(), nil, fleet.ListOptions{Page: 1, PerPage: 1})
software, err := ds.ListSoftware(context.Background(), nil, fleet.ListOptions{Page: 1, PerPage: 1, OrderKey: "version"})
require.NoError(t, err)
require.Len(t, software, 1)
expected := []fleet.Software{foo003}
expected := []fleet.Software{foo002}
test.ElementsMatchSkipID(t, software, expected)
})
@ -447,7 +447,7 @@ func testSoftwareList(t *testing.T, ds *Datastore) {
require.NoError(t, err)
require.NoError(t, ds.AddHostsToTeam(context.Background(), &team1.ID, []uint{host1.ID}))
software, err := ds.ListSoftware(context.Background(), &team1.ID, fleet.ListOptions{})
software, err := ds.ListSoftware(context.Background(), &team1.ID, fleet.ListOptions{OrderKey: "version"})
require.NoError(t, err)
require.Len(t, software, 2)