timeout main

main
Bel LaPointe 2025-04-24 21:12:50 -06:00
parent a174e6834d
commit d14d73bf91
1 changed files with 5 additions and 1 deletions

View File

@ -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)
} }
} }