From 00ef240bea369733157f515ec7f6626bda46984e Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Fri, 13 Dec 2019 15:21:45 +0800 Subject: [PATCH] Delete: test file for task/pool --- pkg/task/pool_test.go | 48 ------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 pkg/task/pool_test.go diff --git a/pkg/task/pool_test.go b/pkg/task/pool_test.go deleted file mode 100644 index f1ea2e5..0000000 --- a/pkg/task/pool_test.go +++ /dev/null @@ -1,48 +0,0 @@ -package task - -import ( - "errors" - "fmt" - "testing" - "time" -) - -type testJob struct { - id string - sleep time.Duration -} - -func (job testJob) Do() error { - fmt.Printf("任务%s开始执行\n", job.id) - time.Sleep(job.sleep * time.Second) - fmt.Printf("任务%s执行完毕\n", job.id) - if job.id == "3" { - return errors.New("error") - } - return nil -} - -func TestPool_Submit(t *testing.T) { - pool := NewGoroutinePool(1) - task1 := testJob{ - id: "1", - sleep: 5, - } - task2 := testJob{ - id: "2", - sleep: 5, - } - task3 := testJob{ - id: "3", - sleep: 2, - } - task4 := testJob{ - id: "4", - sleep: 5, - } - pool.Submit(task1) - pool.Submit(task2) - pool.Submit(task3) - pool.Submit(task4) - pool.Wait() -}