testutil

package
v3.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetArgs

func ResetArgs(t *testing.T, cmd *cobra.Command)

ResetArgs resets arguments for the command. It is desired to be a helpful function for the cmd.SetArgs in the case of calling multiple times in a unit test, as cmd.SetArgs doesn't reset the flag value as expected.

**Warning**: this is only compatible with following flag types:

  1. the implementations of pflag.Value
  2. the built-in implementations of pflag.SliceValue
  3. the custom implementations of pflag.SliceValue that are split by comma ","

see https://github.com/spf13/cobra/issues/2079#issuecomment-1870115781 for more detail info

Types

type MockFlagsWithComma

type MockFlagsWithComma struct {
	Ary []string
	// contains filtered or unexported fields
}

func (*MockFlagsWithComma) Append

func (m *MockFlagsWithComma) Append(value string) error

func (*MockFlagsWithComma) GetSlice

func (m *MockFlagsWithComma) GetSlice() []string

func (*MockFlagsWithComma) Replace

func (m *MockFlagsWithComma) Replace(value []string) error

func (*MockFlagsWithComma) Set

func (m *MockFlagsWithComma) Set(value string) error

func (*MockFlagsWithComma) String

func (m *MockFlagsWithComma) String() string

func (*MockFlagsWithComma) Type

func (m *MockFlagsWithComma) Type() string

type MockFlagsWithSemicolon

type MockFlagsWithSemicolon struct {
	Ary []string
	// contains filtered or unexported fields
}

func (*MockFlagsWithSemicolon) Append

func (m *MockFlagsWithSemicolon) Append(value string) error

func (*MockFlagsWithSemicolon) GetSlice

func (m *MockFlagsWithSemicolon) GetSlice() []string

func (*MockFlagsWithSemicolon) Replace

func (m *MockFlagsWithSemicolon) Replace(value []string) error

func (*MockFlagsWithSemicolon) Set

func (m *MockFlagsWithSemicolon) Set(value string) error

func (*MockFlagsWithSemicolon) String

func (m *MockFlagsWithSemicolon) String() string

func (*MockFlagsWithSemicolon) Type

func (m *MockFlagsWithSemicolon) Type() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL