Skip to content

Commit

Permalink
[test] fix flag state not reset
Browse files Browse the repository at this point in the history
  • Loading branch information
spezifisch committed Oct 14, 2024
1 parent fd3efb2 commit a720e61
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions stmps_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"os"
"runtime"
"testing"
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a720e61

Please sign in to comment.