Skip to content

Commit

Permalink
jobs: clean up always when hopping to the next subtest in TestJobCont…
Browse files Browse the repository at this point in the history
…rolByType

This simplifies reasoning in TestJobControlByType.

Release note: None
  • Loading branch information
knz committed Apr 8, 2023
1 parent 5180bb9 commit cd31dec
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/jobs/delegate_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,11 @@ func TestJobControlByType(t *testing.T) {
}

jobIdsClause := fmt.Sprint(strings.Join(jobIDStrings, ", "))
defer func() {
// Clear the system.jobs table for the next test run.
th.sqlDB.Exec(t, fmt.Sprintf("DELETE FROM system.jobs WHERE id IN (%s)", jobIdsClause))
th.sqlDB.Exec(t, fmt.Sprintf("DELETE FROM system.job_info WHERE job_id IN (%s)", jobIdsClause))
}()

// Execute the command and verify it is executed on the expected number of rows.
numEffected, err := th.cfg.DB.Executor().ExecEx(
Expand Down Expand Up @@ -463,10 +468,6 @@ func TestJobControlByType(t *testing.T) {
),
).Scan(&numJobs)
require.Equal(t, numJobs, numExpectedJobsWithEndState)

// Clear the system.jobs table for the next test run.
th.sqlDB.Exec(t, fmt.Sprintf("DELETE FROM system.jobs WHERE id IN (%s)", jobIdsClause))
th.sqlDB.Exec(t, fmt.Sprintf("DELETE FROM system.job_info WHERE job_id IN (%s)", jobIdsClause))
})
}
}
Expand Down

0 comments on commit cd31dec

Please sign in to comment.