countdown: HA figured the race out

This commit is contained in:
Chris Sexton 2021-12-23 05:58:09 -05:00
parent 3cbbc4a08a
commit 4e16c8f464
1 changed files with 8 additions and 4 deletions

View File

@ -21,10 +21,14 @@ func init() {
}
func setup() (*bot.MockBot, *CountdownPlugin, func()) {
// ensure the scheduled NYE doesn't happen and cause a race
nextYear = time.Now().Add(24 * 365 * time.Hour)
mb := bot.NewMockBot()
cd := New(mb)
return mb, cd, func() {
mb.TearDown()
if err := mb.TearDown(); err != nil {
panic(err)
}
}
}
@ -89,16 +93,16 @@ func TestArchiveCounters(t *testing.T) {
}
count, err := mb.Store().Count(counter.Item{}, &bh.Query{})
assert.Nil(t, err)
assert.Equal(t, count, 3)
assert.Equal(t, 3, count)
err = cd.archiveCounters()
assert.Nil(t, err)
count, err = mb.Store().Count(counter.Item{}, &bh.Query{})
assert.Nil(t, err)
assert.Equal(t, count, 0)
assert.Equal(t, 0, count)
count, err = mb.Store().Count(counterArchive{}, &bh.Query{})
assert.Nil(t, err)
assert.Equal(t, count, 3)
assert.Equal(t, 3, count)
}