Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suppress-summary flag to model test command #407

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions cmd/model/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ var testCmd = &cobra.Command{
return err //nolint:wrapcheck
}

suppressSummary, err := cmd.Flags().GetBool("suppress-summary")
if err != nil {
return err //nolint:wrapcheck
}

test, err := storetest.RunTests(
fgaClient,
storeData,
Expand All @@ -73,13 +78,11 @@ var testCmd = &cobra.Command{
if err != nil {
return fmt.Errorf("error displaying test results due to %w", err)
}

if !passing {
os.Exit(1)
}
}

fmt.Println(test.FriendlyDisplay())
if !suppressSummary {
fmt.Fprintln(os.Stderr, test.FriendlyDisplay())
}

if !passing {
os.Exit(1)
Expand All @@ -94,6 +97,7 @@ func init() {
testCmd.Flags().String("model-id", "", "Model ID")
testCmd.Flags().String("tests", "", "Tests file Name. The file should have the OpenFGA tests in a valid YAML or JSON format") //nolint:lll
testCmd.Flags().Bool("verbose", false, "Print verbose JSON output")
testCmd.Flags().Bool("suppress-summary", false, "Suppress the plain text summary output")

if err := testCmd.MarkFlagRequired("tests"); err != nil {
fmt.Printf("error setting flag as required - %v: %v\n", "cmd/models/test", err)
Expand Down
Loading