diff --git a/internal/command/command_test.go b/internal/command/command_test.go index e66e4484f..b79a29491 100644 --- a/internal/command/command_test.go +++ b/internal/command/command_test.go @@ -3,19 +3,20 @@ package command_test import ( "testing" - "github.com/onflow/flow-cli/internal/command" "github.com/spf13/cobra" + + "github.com/onflow/flow-cli/internal/command" ) func TestAddToParent(t *testing.T) { - cmd := &cobra.Command{} - c := &command.Command{ - Cmd: cmd, - } + cmd := &cobra.Command{} + c := &command.Command{ + Cmd: cmd, + } - c.AddToParent(cmd) + c.AddToParent(cmd) - if c.Cmd.Run == nil { - t.Errorf("Run function was not initialized") - } -} \ No newline at end of file + if c.Cmd.Run == nil { + t.Errorf("Run function was not initialized") + } +} diff --git a/internal/command/flags.go b/internal/command/flags.go index 9ec63651d..33ecc0a9f 100644 --- a/internal/command/flags.go +++ b/internal/command/flags.go @@ -125,7 +125,6 @@ func InitFlags(cmd *cobra.Command) { "Approve any prompts", ) - cmd.PersistentFlags().BoolVarP( &Flags.SkipVersionCheck, "skip-version-check", diff --git a/internal/command/flags_test.go b/internal/command/flags_test.go index 1eb52c2db..ae8a645a3 100644 --- a/internal/command/flags_test.go +++ b/internal/command/flags_test.go @@ -6,36 +6,37 @@ import ( "strings" "testing" - "github.com/onflow/flow-cli/internal/command" "github.com/spf13/cobra" + + "github.com/onflow/flow-cli/internal/command" ) func TestInitFlags(t *testing.T) { - cmd := &cobra.Command{} - command.InitFlags(cmd) + cmd := &cobra.Command{} + command.InitFlags(cmd) - flags := []struct { - name string - expected string - }{ - {"filter", command.Flags.Filter}, - {"format", command.Flags.Format}, - {"save", command.Flags.Save}, - {"host", command.Flags.Host}, - {"network-key", command.Flags.HostNetworkKey}, - {"network", command.Flags.Network}, - {"log", command.Flags.Log}, - {"yes", strconv.FormatBool(command.Flags.Yes)}, - {"config-path", fmt.Sprintf("[%s]",strings.Join(command.Flags.ConfigPaths, ","))}, - {"skip-version-check", strconv.FormatBool(command.Flags.SkipVersionCheck)}, - } + flags := []struct { + name string + expected string + }{ + {"filter", command.Flags.Filter}, + {"format", command.Flags.Format}, + {"save", command.Flags.Save}, + {"host", command.Flags.Host}, + {"network-key", command.Flags.HostNetworkKey}, + {"network", command.Flags.Network}, + {"log", command.Flags.Log}, + {"yes", strconv.FormatBool(command.Flags.Yes)}, + {"config-path", fmt.Sprintf("[%s]", strings.Join(command.Flags.ConfigPaths, ","))}, + {"skip-version-check", strconv.FormatBool(command.Flags.SkipVersionCheck)}, + } - for _, flag := range flags { - f := cmd.PersistentFlags().Lookup(flag.name) - if f == nil { - t.Errorf("Flag %s was not initialized", flag.name) - } else if f.DefValue != flag.expected { - t.Errorf("Flag %s was not initialized with correct default value. Value: %s, Expected: %s", flag.name, f.Value.String(), flag.expected) - } - } -} \ No newline at end of file + for _, flag := range flags { + f := cmd.PersistentFlags().Lookup(flag.name) + if f == nil { + t.Errorf("Flag %s was not initialized", flag.name) + } else if f.DefValue != flag.expected { + t.Errorf("Flag %s was not initialized with correct default value. Value: %s, Expected: %s", flag.name, f.Value.String(), flag.expected) + } + } +}