Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSussman committed Aug 2, 2023
1 parent 37238e6 commit 77375d1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions database/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package database

import (
"context"
"os"
"reflect"
"strings"
Expand Down Expand Up @@ -923,17 +924,19 @@ func testSchedules(t *testing.T, db Interface, resources *Resources) {
methods[element.Method(i).Name] = false
}

ctx := context.TODO()

// create the schedules
for _, schedule := range resources.Schedules {
err := db.CreateSchedule(schedule)
err := db.CreateSchedule(ctx, schedule)
if err != nil {
t.Errorf("unable to create schedule %d: %v", schedule.GetID(), err)
}
}
methods["CreateSchedule"] = true

// count the schedules
count, err := db.CountSchedules()
count, err := db.CountSchedules(ctx)
if err != nil {
t.Errorf("unable to count schedules: %v", err)
}
Expand All @@ -943,7 +946,7 @@ func testSchedules(t *testing.T, db Interface, resources *Resources) {
methods["CountSchedules"] = true

// count the schedules for a repo
count, err = db.CountSchedulesForRepo(resources.Repos[0])
count, err = db.CountSchedulesForRepo(ctx, resources.Repos[0])
if err != nil {
t.Errorf("unable to count schedules for repo %d: %v", resources.Repos[0].GetID(), err)
}
Expand All @@ -953,7 +956,7 @@ func testSchedules(t *testing.T, db Interface, resources *Resources) {
methods["CountSchedulesForRepo"] = true

// list the schedules
list, err := db.ListSchedules()
list, err := db.ListSchedules(ctx)
if err != nil {
t.Errorf("unable to list schedules: %v", err)
}
Expand All @@ -963,7 +966,7 @@ func testSchedules(t *testing.T, db Interface, resources *Resources) {
methods["ListSchedules"] = true

// list the active schedules
list, err = db.ListActiveSchedules()
list, err = db.ListActiveSchedules(ctx)
if err != nil {
t.Errorf("unable to list schedules: %v", err)
}
Expand All @@ -973,7 +976,7 @@ func testSchedules(t *testing.T, db Interface, resources *Resources) {
methods["ListActiveSchedules"] = true

// list the schedules for a repo
list, count, err = db.ListSchedulesForRepo(resources.Repos[0], 1, 10)
list, count, err = db.ListSchedulesForRepo(ctx, resources.Repos[0], 1, 10)
if err != nil {
t.Errorf("unable to count schedules for repo %d: %v", resources.Repos[0].GetID(), err)
}
Expand All @@ -988,7 +991,7 @@ func testSchedules(t *testing.T, db Interface, resources *Resources) {
// lookup the schedules by name
for _, schedule := range resources.Schedules {
repo := resources.Repos[schedule.GetRepoID()-1]
got, err := db.GetScheduleForRepo(repo, schedule.GetName())
got, err := db.GetScheduleForRepo(ctx, repo, schedule.GetName())
if err != nil {
t.Errorf("unable to get schedule %d for repo %d: %v", schedule.GetID(), repo.GetID(), err)
}
Expand All @@ -1001,13 +1004,13 @@ func testSchedules(t *testing.T, db Interface, resources *Resources) {
// update the schedules
for _, schedule := range resources.Schedules {
schedule.SetUpdatedAt(time.Now().UTC().Unix())
err = db.UpdateSchedule(schedule, true)
err = db.UpdateSchedule(ctx, schedule, true)
if err != nil {
t.Errorf("unable to update schedule %d: %v", schedule.GetID(), err)
}

// lookup the schedule by ID
got, err := db.GetSchedule(schedule.GetID())
got, err := db.GetSchedule(ctx, schedule.GetID())
if err != nil {
t.Errorf("unable to get schedule %d by ID: %v", schedule.GetID(), err)
}
Expand All @@ -1020,7 +1023,7 @@ func testSchedules(t *testing.T, db Interface, resources *Resources) {

// delete the schedules
for _, schedule := range resources.Schedules {
err = db.DeleteSchedule(schedule)
err = db.DeleteSchedule(ctx, schedule)
if err != nil {
t.Errorf("unable to delete schedule %d: %v", schedule.GetID(), err)
}
Expand Down

0 comments on commit 77375d1

Please sign in to comment.