timeout main
parent
a174e6834d
commit
d14d73bf91
|
|
@ -6,13 +6,17 @@ import (
|
||||||
"show-rss/src/cmd"
|
"show-rss/src/cmd"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCmdMain(t *testing.T) {
|
func TestCmdMain(t *testing.T) {
|
||||||
ctx, can := signal.NotifyContext(context.Background(), syscall.SIGINT)
|
ctx, can := signal.NotifyContext(context.Background(), syscall.SIGINT)
|
||||||
defer can()
|
defer can()
|
||||||
|
|
||||||
if err := cmd.Main(ctx); err != nil {
|
ctx, can = context.WithTimeout(ctx, 5*time.Second)
|
||||||
|
defer can()
|
||||||
|
|
||||||
|
if err := cmd.Main(ctx); err != nil && ctx.Err() == nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue