From d14d73bf9188fc80c541ba2fbc20a8b790b6b578 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Thu, 24 Apr 2025 21:12:50 -0600 Subject: [PATCH] timeout main --- main_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main_test.go b/main_test.go index 4c5d866..9326499 100644 --- a/main_test.go +++ b/main_test.go @@ -6,13 +6,17 @@ import ( "show-rss/src/cmd" "syscall" "testing" + "time" ) func TestCmdMain(t *testing.T) { ctx, can := signal.NotifyContext(context.Background(), syscall.SIGINT) 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) } }