Skip to content

Commit

Permalink
minimally fix tests (uncomplicated)
Browse files Browse the repository at this point in the history
  • Loading branch information
gulducat committed Apr 9, 2024
1 parent 1f571bd commit 7afc007
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions nomad/jobs_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package nomad

import (
"context"
"strconv"
"testing"
"time"

Expand Down Expand Up @@ -112,7 +113,8 @@ func TestJobs_Statuses(t *testing.T) {

// make sure our state order assumption is correct
for i, j := range resp.Jobs {
must.Eq(t, jobs[i].ID, j.ID, must.Sprintf("jobs not in order; idx=%d", i))
reverse := len(jobs) - i - 1
must.Eq(t, jobs[reverse].ID, j.ID, must.Sprintf("jobs not in order; idx=%d", i))
}

// test various single-job requests
Expand All @@ -128,23 +130,25 @@ func TestJobs_Statuses(t *testing.T) {
qo: structs.QueryOptions{
PerPage: 1,
},
expect: jobs[0],
expect: jobs[4],
},
{
name: "page 2",
qo: structs.QueryOptions{
PerPage: 1,
NextToken: "default." + jobs[1].ID,
PerPage: 1,
// paginator/tokenizer will produce a uint64 of the next job's
// ModifyIndex, so here we just fake that.
NextToken: strconv.FormatUint(jobs[3].ModifyIndex, 10),
},
expect: jobs[1],
expect: jobs[3],
},
{
name: "reverse",
qo: structs.QueryOptions{
PerPage: 1,
Reverse: true,
},
expect: jobs[len(jobs)-1],
expect: jobs[0],
},
{
name: "filter",
Expand Down

0 comments on commit 7afc007

Please sign in to comment.