From 8519480e5598c8004a56383a1658f3e7f3018793 Mon Sep 17 00:00:00 2001 From: "kayos@tcp.direct" Date: Thu, 20 Jun 2024 22:06:57 -0700 Subject: [PATCH] Fix: don't parse flags during unit tests --- internal/config/command_line.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/config/command_line.go b/internal/config/command_line.go index d3b44f5..c875ab9 100644 --- a/internal/config/command_line.go +++ b/internal/config/command_line.go @@ -4,6 +4,7 @@ import ( "flag" "io" "os" + "strings" "github.com/yunginnanet/HellPot/internal/extra" "github.com/yunginnanet/HellPot/internal/version" @@ -12,6 +13,13 @@ import ( var CLIFlags = flag.NewFlagSet("cli", flag.ExitOnError) func init() { + for _, arg := range os.Args { + if strings.Contains(arg, "test.testlogfile") { + // we're in a unit test, bail + return + } + } + CLIFlags.Bool("logger-debug", false, "force debug logging") CLIFlags.Bool("logger-trace", false, "force trace logging") CLIFlags.Bool("logger-nocolor", false, "force no color logging")