Bläddra i källkod

add more tests

kevin 4 år sedan
förälder
incheckning
e7dd04701c
1 ändrade filer med 14 tillägg och 0 borttagningar
  1. 14 0
      core/executors/periodicalexecutor_test.go

+ 14 - 0
core/executors/periodicalexecutor_test.go

@@ -106,6 +106,20 @@ func TestPeriodicalExecutor_Bulk(t *testing.T) {
 	lock.Unlock()
 }
 
+func TestPeriodicalExecutor_Wait(t *testing.T) {
+	var lock sync.Mutex
+	executer := NewBulkExecutor(func(tasks []interface{}) {
+		lock.Lock()
+		defer lock.Unlock()
+		time.Sleep(10 * time.Millisecond)
+	}, WithBulkTasks(1), WithBulkInterval(time.Second))
+	for i := 0; i < 10; i++ {
+		executer.Add(1)
+	}
+	executer.Flush()
+	executer.Wait()
+}
+
 // go test -benchtime 10s -bench .
 func BenchmarkExecutor(b *testing.B) {
 	b.ReportAllocs()