Manager: remove testing.T
parameter from some test setup functions
Replace the use of the `t *testing.T` parameter with just plain `panic()` when test setup fails. This makes it easier to call the same functions from other situations, like benchmark functions. No functional changes to Flamenco itself.
This commit is contained in:
parent
88f90ef0a5
commit
5ec479a983
@ -170,7 +170,7 @@ func TestWorkersLeftToRun(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWorkersLeftToRunWithTags(t *testing.T) {
|
func TestWorkersLeftToRunWithTags(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Create tags.
|
// Create tags.
|
||||||
|
@ -45,7 +45,7 @@ func TestSimpleQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestQueryMetadata(t *testing.T) {
|
func TestQueryMetadata(t *testing.T) {
|
||||||
ctx, close, db := persistenceTestFixtures(t, 0)
|
ctx, close, db := persistenceTestFixtures(0)
|
||||||
defer close()
|
defer close()
|
||||||
|
|
||||||
testJob := persistAuthoredJob(t, ctx, db, createTestAuthoredJobWithTasks())
|
testJob := persistAuthoredJob(t, ctx, db, createTestAuthoredJobWithTasks())
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestStoreAuthoredJob(t *testing.T) {
|
func TestStoreAuthoredJob(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
job := createTestAuthoredJobWithTasks()
|
job := createTestAuthoredJobWithTasks()
|
||||||
@ -59,7 +59,7 @@ func TestStoreAuthoredJob(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStoreAuthoredJobWithShamanCheckoutID(t *testing.T) {
|
func TestStoreAuthoredJobWithShamanCheckoutID(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
job := createTestAuthoredJobWithTasks()
|
job := createTestAuthoredJobWithTasks()
|
||||||
@ -76,7 +76,7 @@ func TestStoreAuthoredJobWithShamanCheckoutID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFetchTaskJobUUID(t *testing.T) {
|
func TestFetchTaskJobUUID(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
job := createTestAuthoredJobWithTasks()
|
job := createTestAuthoredJobWithTasks()
|
||||||
@ -91,7 +91,7 @@ func TestFetchTaskJobUUID(t *testing.T) {
|
|||||||
func TestSaveJobStorageInfo(t *testing.T) {
|
func TestSaveJobStorageInfo(t *testing.T) {
|
||||||
// Test that saving job storage info doesn't count as "update".
|
// Test that saving job storage info doesn't count as "update".
|
||||||
// This is necessary for `cmd/shaman-checkout-id-setter` to do its work quietly.
|
// This is necessary for `cmd/shaman-checkout-id-setter` to do its work quietly.
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
startTime := time.Date(2023, time.February, 7, 15, 0, 0, 0, time.UTC)
|
startTime := time.Date(2023, time.February, 7, 15, 0, 0, 0, time.UTC)
|
||||||
@ -122,7 +122,7 @@ func TestSaveJobStorageInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSaveJobPriority(t *testing.T) {
|
func TestSaveJobPriority(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Create test job.
|
// Create test job.
|
||||||
@ -146,7 +146,7 @@ func TestSaveJobPriority(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteJob(t *testing.T) {
|
func TestDeleteJob(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
authJob := createTestAuthoredJobWithTasks()
|
authJob := createTestAuthoredJobWithTasks()
|
||||||
@ -193,7 +193,7 @@ func TestDeleteJob(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFetchJobShamanCheckoutID(t *testing.T) {
|
func TestFetchJobShamanCheckoutID(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
authJob := createTestAuthoredJobWithTasks()
|
authJob := createTestAuthoredJobWithTasks()
|
||||||
@ -216,7 +216,7 @@ func TestFetchJobShamanCheckoutID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteJobWithoutFK(t *testing.T) {
|
func TestDeleteJobWithoutFK(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
authJob := createTestAuthoredJobWithTasks()
|
authJob := createTestAuthoredJobWithTasks()
|
||||||
@ -919,7 +919,7 @@ func createTestAuthoredJob(jobID string, tasks ...job_compilers.AuthoredTask) jo
|
|||||||
return job
|
return job
|
||||||
}
|
}
|
||||||
|
|
||||||
func persistAuthoredJob(t *testing.T, ctx context.Context, db *DB, authoredJob job_compilers.AuthoredJob) *Job {
|
func persistAuthoredJob(t require.TestingT, ctx context.Context, db *DB, authoredJob job_compilers.AuthoredJob) *Job {
|
||||||
err := db.StoreAuthoredJob(ctx, authoredJob)
|
err := db.StoreAuthoredJob(ctx, authoredJob)
|
||||||
require.NoError(t, err, "error storing authored job in DB")
|
require.NoError(t, err, "error storing authored job in DB")
|
||||||
|
|
||||||
@ -968,7 +968,7 @@ func duplicateJobAndTasks(job job_compilers.AuthoredJob) job_compilers.AuthoredJ
|
|||||||
}
|
}
|
||||||
|
|
||||||
func jobTasksTestFixtures(t *testing.T) (context.Context, context.CancelFunc, *DB, *Job, job_compilers.AuthoredJob) {
|
func jobTasksTestFixtures(t *testing.T) (context.Context, context.CancelFunc, *DB, *Job, job_compilers.AuthoredJob) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
|
|
||||||
authoredJob := createTestAuthoredJobWithTasks()
|
authoredJob := createTestAuthoredJobWithTasks()
|
||||||
dbJob := persistAuthoredJob(t, ctx, db, authoredJob)
|
dbJob := persistAuthoredJob(t, ctx, db, authoredJob)
|
||||||
@ -978,7 +978,7 @@ func jobTasksTestFixtures(t *testing.T) (context.Context, context.CancelFunc, *D
|
|||||||
|
|
||||||
// This created Test Jobs using the new function createTestAuthoredJobWithNumTasks so that you can set the number of tasks
|
// This created Test Jobs using the new function createTestAuthoredJobWithNumTasks so that you can set the number of tasks
|
||||||
func jobTasksTestFixturesWithTaskNum(t *testing.T, numtasks int) (context.Context, context.CancelFunc, *DB, *Job, job_compilers.AuthoredJob) {
|
func jobTasksTestFixturesWithTaskNum(t *testing.T, numtasks int) (context.Context, context.CancelFunc, *DB, *Job, job_compilers.AuthoredJob) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeoutlong)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeoutlong)
|
||||||
|
|
||||||
authoredJob := createTestAuthoredJobWithNumTasks(numtasks)
|
authoredJob := createTestAuthoredJobWithNumTasks(numtasks)
|
||||||
dbJob := persistAuthoredJob(t, ctx, db, authoredJob)
|
dbJob := persistAuthoredJob(t, ctx, db, authoredJob)
|
||||||
|
@ -19,7 +19,7 @@ const schedulerTestTimeout = 100 * time.Millisecond
|
|||||||
const schedulerTestTimeoutlong = 5000 * time.Millisecond
|
const schedulerTestTimeoutlong = 5000 * time.Millisecond
|
||||||
|
|
||||||
func TestNoTasks(t *testing.T) {
|
func TestNoTasks(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
w := linuxWorker(t, db)
|
w := linuxWorker(t, db)
|
||||||
@ -30,7 +30,7 @@ func TestNoTasks(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOneJobOneTask(t *testing.T) {
|
func TestOneJobOneTask(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
w := linuxWorker(t, db)
|
w := linuxWorker(t, db)
|
||||||
@ -67,7 +67,7 @@ func TestOneJobOneTask(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOneJobThreeTasksByPrio(t *testing.T) {
|
func TestOneJobThreeTasksByPrio(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
w := linuxWorker(t, db)
|
w := linuxWorker(t, db)
|
||||||
@ -98,7 +98,7 @@ func TestOneJobThreeTasksByPrio(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOneJobThreeTasksByDependencies(t *testing.T) {
|
func TestOneJobThreeTasksByDependencies(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
w := linuxWorker(t, db)
|
w := linuxWorker(t, db)
|
||||||
@ -124,7 +124,7 @@ func TestOneJobThreeTasksByDependencies(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTwoJobsThreeTasks(t *testing.T) {
|
func TestTwoJobsThreeTasks(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
w := linuxWorker(t, db)
|
w := linuxWorker(t, db)
|
||||||
@ -167,7 +167,7 @@ func TestSomeButNotAllDependenciesCompleted(t *testing.T) {
|
|||||||
// There was a bug in the task scheduler query, where it would schedule a task
|
// There was a bug in the task scheduler query, where it would schedule a task
|
||||||
// if any of its dependencies was completed (instead of all dependencies).
|
// if any of its dependencies was completed (instead of all dependencies).
|
||||||
// This test reproduces that problematic scenario.
|
// This test reproduces that problematic scenario.
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
att1 := authorTestTask("1.1 completed task", "blender")
|
att1 := authorTestTask("1.1 completed task", "blender")
|
||||||
@ -190,7 +190,7 @@ func TestSomeButNotAllDependenciesCompleted(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAlreadyAssigned(t *testing.T) {
|
func TestAlreadyAssigned(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
w := linuxWorker(t, db)
|
w := linuxWorker(t, db)
|
||||||
@ -226,7 +226,7 @@ func TestAlreadyAssigned(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAssignedToOtherWorker(t *testing.T) {
|
func TestAssignedToOtherWorker(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
w := linuxWorker(t, db)
|
w := linuxWorker(t, db)
|
||||||
@ -262,7 +262,7 @@ func TestAssignedToOtherWorker(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPreviouslyFailed(t *testing.T) {
|
func TestPreviouslyFailed(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
w := linuxWorker(t, db)
|
w := linuxWorker(t, db)
|
||||||
@ -292,7 +292,7 @@ func TestPreviouslyFailed(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWorkerTagJobWithTag(t *testing.T) {
|
func TestWorkerTagJobWithTag(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Create worker tags:
|
// Create worker tags:
|
||||||
@ -341,7 +341,7 @@ func TestWorkerTagJobWithTag(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWorkerTagJobWithoutTag(t *testing.T) {
|
func TestWorkerTagJobWithoutTag(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Create worker tag:
|
// Create worker tag:
|
||||||
@ -376,7 +376,7 @@ func TestWorkerTagJobWithoutTag(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBlocklisted(t *testing.T) {
|
func TestBlocklisted(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, schedulerTestTimeout)
|
ctx, cancel, db := persistenceTestFixtures(schedulerTestTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
w := linuxWorker(t, db)
|
w := linuxWorker(t, db)
|
||||||
|
@ -6,6 +6,7 @@ package persistence
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -22,11 +23,11 @@ import (
|
|||||||
// resulting database.
|
// resulting database.
|
||||||
const TestDSN = "file::memory:"
|
const TestDSN = "file::memory:"
|
||||||
|
|
||||||
func CreateTestDB(t *testing.T) (db *DB, closer func()) {
|
func CreateTestDB() (db *DB, closer func()) {
|
||||||
// Delete the SQLite file if it exists on disk.
|
// Delete the SQLite file if it exists on disk.
|
||||||
if _, err := os.Stat(TestDSN); err == nil {
|
if _, err := os.Stat(TestDSN); err == nil {
|
||||||
if err := os.Remove(TestDSN); err != nil {
|
if err := os.Remove(TestDSN); err != nil {
|
||||||
t.Fatalf("unable to remove %s: %v", TestDSN, err)
|
panic(fmt.Sprintf("unable to remove %s: %v", TestDSN, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ func CreateTestDB(t *testing.T) (db *DB, closer func()) {
|
|||||||
// can be closed when the unit test is done running.
|
// can be closed when the unit test is done running.
|
||||||
sqliteConn, err := sql.Open(sqlite.DriverName, TestDSN)
|
sqliteConn, err := sql.Open(sqlite.DriverName, TestDSN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("opening SQLite connection: %v", err)
|
panic(fmt.Sprintf("opening SQLite connection: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
config := gorm.Config{
|
config := gorm.Config{
|
||||||
@ -49,19 +50,19 @@ func CreateTestDB(t *testing.T) (db *DB, closer func()) {
|
|||||||
|
|
||||||
db, err = openDBWithConfig(TestDSN, &config)
|
db, err = openDBWithConfig(TestDSN, &config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("opening DB: %v", err)
|
panic(fmt.Sprintf("opening DB: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
err = db.migrate(ctx)
|
err = db.migrate(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("migrating DB: %v", err)
|
panic(fmt.Sprintf("migrating DB: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
closer = func() {
|
closer = func() {
|
||||||
if err := db.Close(); err != nil {
|
if err := db.Close(); err != nil {
|
||||||
t.Fatalf("closing DB: %v", err)
|
panic(fmt.Sprintf("closing DB: %v", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +71,8 @@ func CreateTestDB(t *testing.T) (db *DB, closer func()) {
|
|||||||
|
|
||||||
// persistenceTestFixtures creates a test database and returns it and a context.
|
// persistenceTestFixtures creates a test database and returns it and a context.
|
||||||
// Tests should call the returned cancel function when they're done.
|
// Tests should call the returned cancel function when they're done.
|
||||||
func persistenceTestFixtures(t *testing.T, testContextTimeout time.Duration) (context.Context, context.CancelFunc, *DB) {
|
func persistenceTestFixtures(testContextTimeout time.Duration) (context.Context, context.CancelFunc, *DB) {
|
||||||
db, dbCloser := CreateTestDB(t)
|
db, dbCloser := CreateTestDB()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
@ -102,7 +103,7 @@ type WorkerTestFixture struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func workerTestFixtures(t *testing.T, testContextTimeout time.Duration) WorkerTestFixture {
|
func workerTestFixtures(t *testing.T, testContextTimeout time.Duration) WorkerTestFixture {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, testContextTimeout)
|
ctx, cancel, db := persistenceTestFixtures(testContextTimeout)
|
||||||
|
|
||||||
w := Worker{
|
w := Worker{
|
||||||
UUID: "557930e7-5b55-469e-a6d7-fc800f3685be",
|
UUID: "557930e7-5b55-469e-a6d7-fc800f3685be",
|
||||||
|
@ -51,7 +51,7 @@ func TestFetchTimedOutTasks(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFetchTimedOutWorkers(t *testing.T) {
|
func TestFetchTimedOutWorkers(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
timeoutDeadline := mustParseTime("2022-06-07T11:14:47+02:00")
|
timeoutDeadline := mustParseTime("2022-06-07T11:14:47+02:00")
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestFetchWorkerSleepSchedule(t *testing.T) {
|
func TestFetchWorkerSleepSchedule(t *testing.T) {
|
||||||
ctx, finish, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, finish, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer finish()
|
defer finish()
|
||||||
|
|
||||||
linuxWorker := Worker{
|
linuxWorker := Worker{
|
||||||
@ -57,7 +57,7 @@ func TestFetchWorkerSleepSchedule(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFetchSleepScheduleWorker(t *testing.T) {
|
func TestFetchSleepScheduleWorker(t *testing.T) {
|
||||||
ctx, finish, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, finish, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer finish()
|
defer finish()
|
||||||
|
|
||||||
linuxWorker := Worker{
|
linuxWorker := Worker{
|
||||||
@ -104,7 +104,7 @@ func TestFetchSleepScheduleWorker(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSetWorkerSleepSchedule(t *testing.T) {
|
func TestSetWorkerSleepSchedule(t *testing.T) {
|
||||||
ctx, finish, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, finish, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer finish()
|
defer finish()
|
||||||
|
|
||||||
linuxWorker := Worker{
|
linuxWorker := Worker{
|
||||||
@ -187,7 +187,7 @@ func TestSetWorkerSleepSchedule(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSetWorkerSleepScheduleNextCheck(t *testing.T) {
|
func TestSetWorkerSleepScheduleNextCheck(t *testing.T) {
|
||||||
ctx, finish, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, finish, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer finish()
|
defer finish()
|
||||||
|
|
||||||
schedule := SleepSchedule{
|
schedule := SleepSchedule{
|
||||||
@ -218,7 +218,7 @@ func TestSetWorkerSleepScheduleNextCheck(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFetchSleepSchedulesToCheck(t *testing.T) {
|
func TestFetchSleepSchedulesToCheck(t *testing.T) {
|
||||||
ctx, finish, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, finish, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer finish()
|
defer finish()
|
||||||
|
|
||||||
mockedNow := mustParseTime("2022-06-07T11:14:47+02:00").UTC()
|
mockedNow := mustParseTime("2022-06-07T11:14:47+02:00").UTC()
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateFetchWorker(t *testing.T) {
|
func TestCreateFetchWorker(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Test fetching non-existent worker
|
// Test fetching non-existent worker
|
||||||
@ -54,7 +54,7 @@ func TestCreateFetchWorker(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFetchWorkerTask(t *testing.T) {
|
func TestFetchWorkerTask(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 10*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(10 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Worker without task.
|
// Worker without task.
|
||||||
@ -135,7 +135,7 @@ func TestFetchWorkerTask(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSaveWorker(t *testing.T) {
|
func TestSaveWorker(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
w := Worker{
|
w := Worker{
|
||||||
@ -190,7 +190,7 @@ func TestSaveWorker(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFetchWorkers(t *testing.T) {
|
func TestFetchWorkers(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// No workers
|
// No workers
|
||||||
@ -250,7 +250,7 @@ func TestFetchWorkers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteWorker(t *testing.T) {
|
func TestDeleteWorker(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Test deleting non-existent worker
|
// Test deleting non-existent worker
|
||||||
@ -315,7 +315,7 @@ func TestDeleteWorker(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteWorkerNoForeignKeys(t *testing.T) {
|
func TestDeleteWorkerNoForeignKeys(t *testing.T) {
|
||||||
ctx, cancel, db := persistenceTestFixtures(t, 1*time.Second)
|
ctx, cancel, db := persistenceTestFixtures(1 * time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Create a Worker to delete.
|
// Create a Worker to delete.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user