Skip to content

Commit

Permalink
fix unrelated test that was leaking scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRoesler committed Jan 17, 2024
1 parent 2d8daf5 commit 151a857
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,7 @@ func TestScheduler_OneTimeJob(t *testing.T) {
}

func TestScheduler_Jobs(t *testing.T) {
goleak.VerifyNone(t)
tests := []struct {
name string
}{
Expand All @@ -1657,6 +1658,7 @@ func TestScheduler_Jobs(t *testing.T) {
jobsSecond := s.Jobs()

assert.Equal(t, jobsFirst, jobsSecond)
assert.NoError(t, s.Shutdown())
})
}
}
Expand Down Expand Up @@ -1711,17 +1713,16 @@ func TestScheduler_WithMonitor(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ch := make(chan struct{}, 20)
testMonitor := newTestMonitor()
s, err := NewScheduler(WithMonitor(testMonitor))
require.NoError(t, err)
monitor := newTestMonitor()
s := newTestScheduler(t, WithMonitor(monitor))

opt := []JobOption{
WithName(tt.jobName),
WithStartAt(
WithStartImmediately(),
),
}
_, err = s.NewJob(
_, err := s.NewJob(
tt.jd,
NewTask(func() {
ch <- struct{}{}
Expand All @@ -1738,7 +1739,7 @@ func TestScheduler_WithMonitor(t *testing.T) {
expectedCount++
}

got := testMonitor.counter[tt.jobName]
got := monitor.counter[tt.jobName]
if got != expectedCount {
t.Fatalf("job %q counter expected %d, got %d", tt.jobName, expectedCount, got)
}
Expand Down

0 comments on commit 151a857

Please sign in to comment.