From e7b08ab3d02bc8d986ee2c2264460263a03fdbe3 Mon Sep 17 00:00:00 2001 From: Albert Nigmatzianov Date: Sun, 14 May 2017 12:25:28 +0200 Subject: [PATCH] Fix 'unused' and 'gosimple' complaints --- cobra_test.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cobra_test.go b/cobra_test.go index 6f7032c6..576c97d3 100644 --- a/cobra_test.go +++ b/cobra_test.go @@ -13,13 +13,12 @@ import ( "github.com/spf13/pflag" ) -var tp, te, tt, t1, tr []string +var tp, te, tt, tr []string var rootPersPre, echoPre, echoPersPre, timesPersPre []string var flagb1, flagb2, flagb3, flagbr, flagbp bool var flags1, flags2a, flags2b, flags3, outs string var flagi1, flagi2, flagi3, flagi4, flagir int -var globalFlag1 bool -var flagEcho, rootcalled bool +var rootcalled bool var versionUsed int const strtwoParentHelp = "help message for parent flag strtwo" @@ -717,7 +716,7 @@ func TestNonRunChildHelp(t *testing.T) { func TestRunnableRootCommand(t *testing.T) { x := fullSetupTest("") - if rootcalled != true { + if !rootcalled { t.Errorf("Root Function was not called\n out:%v", x.Error) } } @@ -765,7 +764,7 @@ func TestRunnableRootCommandNilInput(t *testing.T) { t.Errorf("Execute() failed with %v", err) } - if rootcalled != true { + if !rootcalled { t.Errorf("Root Function was not called") } } @@ -783,8 +782,8 @@ func TestRunnableRootCommandEmptyInput(t *testing.T) { c.Execute() - if rootcalled != true { - t.Errorf("Root Function was not called.\n\nOutput was:\n\n%s\n", buf) + if !rootcalled { + t.Errorf("Root Function was not called.\nOutput was:\n%s\n", buf) } } @@ -799,7 +798,7 @@ func TestInvalidSubcommandWhenArgsAllowed(t *testing.T) { func TestRootFlags(t *testing.T) { fullSetupTest("-i", "17", "-b") - if flagbr != true { + if !flagbr { t.Errorf("flag value should be true, %v given", flagbr) } @@ -1084,7 +1083,7 @@ func TestPeristentPreRunPropagation(t *testing.T) { rootCmd.SetArgs([]string{"print", "echosub", "lala"}) rootCmd.Execute() - if rootPersPre == nil || len(rootPersPre) == 0 || rootPersPre[0] != "lala" { + if len(rootPersPre) == 0 || rootPersPre[0] != "lala" { t.Error("RootCmd PersistentPreRun not called but should have been") } }