testutil

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommand

func NewCommand(use string, runE func(cmd *cobra.Command, args []string) error) *cobra.Command

NewCommand creates a cobra.Command with the given use string and RunE, pre-configured with the --output flag defaulting to "table".

func NoColorAdapter

func NoColorAdapter(fn func(cmd *cobra.Command, args []string, noColor bool) error) func(cmd *cobra.Command, args []string) error

NoColorAdapter wraps a function that takes (cmd, args, noColor) into a standard cobra RunE, always passing noColor=true for tests.

func OutputAdapter

func OutputAdapter(fn func(cmd *cobra.Command, args []string, noColor bool, outputFormat string) error) func(cmd *cobra.Command, args []string) error

OutputAdapter wraps a function that takes (cmd, args, noColor, outputFormat) into a standard cobra RunE. It reads --output from the command flags, defaulting to "table".

func SetFlags

func SetFlags(t *testing.T, cmd *cobra.Command, flags map[string]string)

SetFlags sets multiple string flag values on a command, calling t.Fatalf on any error.

func SetupLogin

func SetupLogin(setupFn func(*megaport.Client)) func()

SetupLogin saves the current login function, replaces it with one that returns a client configured by setupFn, and returns a cleanup function that restores the original.

func SetupLoginError

func SetupLoginError(err error) func()

SetupLoginError saves the current login function, replaces it with one that returns the given error, and returns a cleanup function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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