Test: tasks pkg

This commit is contained in:
HFO4
2021-11-20 17:14:45 +08:00
parent 9056ef9171
commit 96b84bb5e5
7 changed files with 44 additions and 12 deletions

View File

@@ -29,10 +29,10 @@ func TestMain(m *testing.M) {
func TestInit(t *testing.T) {
asserts := assert.New(t)
cache.Set("setting_max_worker_num", "10", 0)
mock.ExpectQuery("SELECT(.+)").WithArgs(Queued).WillReturnRows(sqlmock.NewRows([]string{"type"}).AddRow(-1))
mock.ExpectQuery("SELECT(.+)").WithArgs(Queued, Processing).WillReturnRows(sqlmock.NewRows([]string{"type"}).AddRow(-1))
Init()
asserts.NoError(mock.ExpectationsWereMet())
asserts.Len(TaskPoll.idleWorker, 10)
asserts.Len(TaskPoll.(*AsyncPool).idleWorker, 10)
}
func TestPool_Submit(t *testing.T) {