Skip to content

Commit

Permalink
Fix exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
zix99 committed Jul 25, 2023
1 parent b67917e commit 313f06f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions cmd/bargraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"rare/cmd/helpers"
"rare/pkg/aggregation"
"rare/pkg/csv"
"rare/pkg/logger"
"rare/pkg/multiterm/termrenderers"

"github.com/urfave/cli/v2"
Expand All @@ -28,7 +27,7 @@ func bargraphFunction(c *cli.Context) error {
writer.Stacked = stacked
if c.IsSet(helpers.ScaleFlag.Name) {
if stacked {
logger.Fatal("Unable to set graph scale on stacked graphs")
return cli.Exit("Unable to set graph scale on stacked graphs", helpers.ExitCodeInvalidUsage)
}
writer.Scaler = helpers.BuildScalerOrFail(scaleName)
}
Expand Down
11 changes: 10 additions & 1 deletion cmd/bargraph_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package cmd

import "testing"
import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestBarGraph(t *testing.T) {
testCommandSet(t, bargraphCommand(),
Expand All @@ -9,3 +13,8 @@ func TestBarGraph(t *testing.T) {
`-o - -m "(.+) (\d+)" -e "{$ {1} {2}}" --scale log10 testdata/graph.txt`,
)
}

func TestBarGraphCantScaleAndStack(t *testing.T) {
err := testCommand(bargraphCommand(), "--stacked --scale log10 testdata/graph.txt")
assert.Error(t, err)
}

0 comments on commit 313f06f

Please sign in to comment.