From 816ae35d40fd9a6310c410e1e75dcce9939beeea Mon Sep 17 00:00:00 2001 From: Siddhant Khare Date: Tue, 15 Oct 2024 15:45:43 +0000 Subject: [PATCH 1/2] chore: Add `suppress-summary` flag to test command --- cmd/model/test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/model/test.go b/cmd/model/test.go index 606b925..0e703db 100644 --- a/cmd/model/test.go +++ b/cmd/model/test.go @@ -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, @@ -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) @@ -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) From 9681e4961b268b67450a407028ceb138330353ef Mon Sep 17 00:00:00 2001 From: Siddhant Khare Date: Wed, 16 Oct 2024 16:09:04 +0000 Subject: [PATCH 2/2] lint fix --- cmd/model/test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/model/test.go b/cmd/model/test.go index 0e703db..a3d97bc 100644 --- a/cmd/model/test.go +++ b/cmd/model/test.go @@ -58,9 +58,9 @@ var testCmd = &cobra.Command{ } suppressSummary, err := cmd.Flags().GetBool("suppress-summary") - if err != nil { - return err //nolint:wrapcheck - } + if err != nil { + return err //nolint:wrapcheck + } test, err := storetest.RunTests( fgaClient,