From a720e6188862e3b9f284829c2b5408e76f7e074a Mon Sep 17 00:00:00 2001 From: spezifisch Date: Mon, 14 Oct 2024 19:31:23 +0200 Subject: [PATCH] [test] fix flag state not reset --- stmps_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stmps_test.go b/stmps_test.go index 5420264..a08da3f 100644 --- a/stmps_test.go +++ b/stmps_test.go @@ -1,6 +1,7 @@ package main import ( + "flag" "os" "runtime" "testing" @@ -19,6 +20,9 @@ func TestPlayerInitialization(t *testing.T) { } func TestMainWithoutTUI(t *testing.T) { + // Reset flags before each test, needed for flag usage in main() + flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError) + // Mock osExit to prevent actual exit during test exitCalled := false osExit = func(code int) { @@ -57,6 +61,9 @@ func TestMainWithoutTUI(t *testing.T) { // Regression test for https://github.com/spezifisch/stmps/issues/70 func TestMainWithConfigFileEmptyString(t *testing.T) { + // Reset flags before each test + flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError) + // Mock osExit to prevent actual exit during test exitCalled := false osExit = func(code int) {