test

package
v0.113.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgumentSuite

type ArgumentSuite struct {
	Cmd       string         // Cmd appends to the safecli.Builder before test if not empty.
	Arguments []ArgumentTest // Tests to run.
}

ArgumentSuite defines a suite of tests for a single ArgumentTest.

func (*ArgumentSuite) TestArguments

func (s *ArgumentSuite) TestArguments(c *check.C)

TestArguments runs all tests in the suite.

type ArgumentTest

type ArgumentTest struct {
	test.ArgumentTest

	Logger      log.Logger // Logger is the logger to use for the test. (optional)
	LoggerRegex []string   // LoggerRegex is a list of regexs to match against the log output. (optional)
}

ArgumentTest extends test.ArgumentTest to include logger tests.

func (*ArgumentTest) Test

func (t *ArgumentTest) Test(c *check.C, cmd string)

Test runs the test with the given command and checks the log output.

type CommandSuite

type CommandSuite struct {
	Commands []CommandTest
}

CommandSuite defines a test suite for commands.

func NewCommandSuite

func NewCommandSuite(commands []CommandTest) *CommandSuite

NewCommandSuite creates a new CommandSuite.

func (*CommandSuite) TestCommands

func (s *CommandSuite) TestCommands(c *check.C)

TestCommands runs all tests in the suite.

type CommandTest

type CommandTest struct {
	// Name of the test. (required)
	Name string

	// Command to test. (required)
	Command func() (*safecli.Builder, error)

	// Expected CLI arguments. (optional)
	ExpectedCLI []string

	// Expected log output. (optional)
	// if empty, it will be set to ExpectedCLI joined with space.
	// if empty and ExpectedCLI is empty, it will be ignored.
	ExpectedLog string

	// Expected error. (optional)
	// If nil, no error is expected and
	// ExpectedCLI and ExpectedLog are checked.
	ExpectedErr error
}

CommandTest defines a single test for a command.

func (*CommandTest) CheckCommentString

func (t *CommandTest) CheckCommentString() string

CheckCommentString implements check.CommentInterface

func (*CommandTest) Test

func (t *CommandTest) Test(c *check.C)

Jump to

Keyboard shortcuts

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