diff --git a/flagrun.go b/flagrun.go index b4964d5..3b9d314 100644 --- a/flagrun.go +++ b/flagrun.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "path/filepath" "reflect" "runtime" "runtime/debug" @@ -211,15 +212,18 @@ func (f *Flagrun) internalChecker( if chk == nil { return "UNKNOWN: checker returned nil", UNKNOWN } + if chk.Name == "" { + chk.Name = filepath.Base(os.Args[0]) + } switch chk.Status { case checkers.OK: - return chk.String(), OK + return chk.String(), OK case checkers.WARNING: - return chk.String(), WARNING + return chk.String(), WARNING case checkers.CRITICAL: - return chk.String(), CRITICAL + return chk.String(), CRITICAL default: - return chk.String(), UNKNOWN + return chk.String(), UNKNOWN } } diff --git a/flagrun_check_test.go b/flagrun_check_test.go index 0bf826e..aad962c 100644 --- a/flagrun_check_test.go +++ b/flagrun_check_test.go @@ -67,7 +67,7 @@ func TestInternalChecker(t *testing.T) { stdoutStr := stdout.String() assert.Equal(t, "", stdoutStr) - assert.Equal(t, tt.wantStdout, msg) + assert.Equal(t, "flagrun.test"+tt.wantStdout, msg) assert.Equal(t, tt.wantCode, code) }) }