init project

This commit is contained in:
admin committed 2026-11-11 17:49:38 +08:00
1 parent d63cc8d9f5
commit ee07869839
39 files changed
+1560 -622

No files matched your search

+31
View File
@@ -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")
}
}