init project
This commit is contained in:
1 parent
d63cc8d9f5
commit
ee07869839
39 files changed
+1560
-622
No files matched your search
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"micro_layout/cmd/crontab/config"
|
||||
)
|
||||
|
||||
func TestRunCrontabStopsOnCancellation(t *testing.T) {
|
||||
conf = &config.Config{}
|
||||
conf.Server.ShutdownTimeout = time.Second
|
||||
wg = &sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
result := make(chan error, 1)
|
||||
go func() { result <- runCrontab(ctx) }()
|
||||
cancel()
|
||||
select {
|
||||
case err := <-result:
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wg.Wait()
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Fatal("crontab did not stop after cancellation")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user