Documentation ¶
Overview ¶
Contains support for automating the use of the rad CLI
Index ¶
- Constants
- func Create404Error() error
- func CreateResource(resourceType string, resourceName string) generated.GenericResource
- func CreateResourceGroup(resourceGroupName string) v20231001preview.ResourceGroupResource
- func LoadConfig(t *testing.T, yamlData string) *viper.Viper
- func LoadConfigWithWorkspace(t *testing.T) *viper.Viper
- func LoadEmptyConfig(t *testing.T) *viper.Viper
- func SharedCommandValidation(t *testing.T, ...)
- func SharedValidateValidation(t *testing.T, ...)
- type CLI
- func (cli *CLI) ApplicationDelete(ctx context.Context, applicationName string) error
- func (cli *CLI) ApplicationShow(ctx context.Context, applicationName string) (string, error)
- func (cli *CLI) BicepPublish(ctx context.Context, file, target string) (string, error)
- func (cli *CLI) CliVersion(ctx context.Context) (string, error)
- func (cli *CLI) CreateCommand(ctx context.Context, args []string) (*exec.Cmd, func(<-chan struct{}), string)
- func (cli *CLI) Deploy(ctx context.Context, templateFilePath string, environment string, ...) error
- func (cli *CLI) EnvDelete(ctx context.Context, environmentName string) error
- func (cli *CLI) RecipeList(ctx context.Context, envName string) (string, error)
- func (cli *CLI) RecipeRegister(ctx context.Context, ...) (string, error)
- func (cli *CLI) RecipeShow(ctx context.Context, envName, recipeName string, resourceType string) (string, error)
- func (cli *CLI) RecipeUnregister(ctx context.Context, envName, recipeName, resourceType string) (string, error)
- func (cli *CLI) ReportCommandResult(ctx context.Context, out string, description string, err error) error
- func (cli *CLI) ResourceExpose(ctx context.Context, applicationName string, resourceName string, ...) (string, error)
- func (cli *CLI) ResourceList(ctx context.Context, applicationName string) (string, error)
- func (cli *CLI) ResourceLogs(ctx context.Context, applicationName string, resourceName string) (string, error)
- func (cli *CLI) ResourceShow(ctx context.Context, resourceType string, resourceName string) (string, error)
- func (cli *CLI) RunCommand(ctx context.Context, args []string) (string, error)
- func (cli *CLI) Version(ctx context.Context) (string, error)
- type CLIError
- type ValidateInput
- type ValidateMocks
Constants ¶
const ( TestWorkspaceName = "test-workspace" TestEnvironmentName = "test-environment" TestEnvironmentID = "/planes/radius/local/resourceGroups/test-resource-group/providers/Applications.Core/environments/test-environment" )
const (
HeartbeatInterval = 10 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func Create404Error ¶
func Create404Error() error
Create404Error creates an error with a status code of 404.
func CreateResource ¶
func CreateResource(resourceType string, resourceName string) generated.GenericResource
CreateResource creates a generic resource with the given resource type and name, and sets the ID, Name, Type and Location fields.
func CreateResourceGroup ¶
func CreateResourceGroup(resourceGroupName string) v20231001preview.ResourceGroupResource
// CreateResourceGroup creates a ResourceGroupResource object with the given name and a generated ID.
func LoadConfig ¶
LoadConfig reads a YAML configuration from a string and returns a Viper object.
func LoadConfigWithWorkspace ¶
LoadConfigWithWorkspace loads a config with a workspace and returns a viper instance.
func LoadEmptyConfig ¶
LoadEmptyConfig creates a viper instance with an empty workspaces configuration.
func SharedCommandValidation ¶
func SharedCommandValidation(t *testing.T, factory func(framework framework.Factory) (*cobra.Command, framework.Runner))
SharedCommandValidation tests that the command created by the factory function has all the required fields set.
func SharedValidateValidation ¶
func SharedValidateValidation(t *testing.T, factory func(framework framework.Factory) (*cobra.Command, framework.Runner), testcases []ValidateInput)
SharedValidateValidation runs a series of tests to validate command line arguments and flags, and returns an error if validation fails.
Types ¶
type CLI ¶
func (*CLI) ApplicationDelete ¶
ApplicationDelete deletes the specified application deployed by Radius and returns an error if one occurs.
func (*CLI) ApplicationShow ¶
ApplicationShow returns the output of running the "application show" command with the given application name as an argument, or an error if the command fails.
func (*CLI) BicepPublish ¶
BicepPublish runs the bicep publish command with the given file and target, and returns the output string or an error if the command fails.
func (*CLI) CliVersion ¶
CliVersion retrieves the version of the CLI by running the "version --cli" command.
func (*CLI) CreateCommand ¶
func (cli *CLI) CreateCommand(ctx context.Context, args []string) (*exec.Cmd, func(<-chan struct{}), string)
CreateCommand creates an exec.Cmd that can be used to execute a `rad` CLI command. Most tests should use RunCommand, only use CreateCommand if the test you are writing needs more control over the execution of the command.
The second return value is the 'heartbeat' func. Tests using this function should start the heartbeat in a goroutine to produce logs while the command is running. The third return value is the command description which can be used in error messages.
func (*CLI) Deploy ¶
func (cli *CLI) Deploy(ctx context.Context, templateFilePath string, environment string, application string, parameters ...string) error
Deploy runs the rad deploy command. It checks if the template file path exists and runs the command with the given parameters, returning an error if the command fails.
func (*CLI) EnvDelete ¶
EnvDelete runs the command to delete an environment with the given name and returns an error if the command fails.
func (*CLI) RecipeList ¶
RecipeList runs the "recipe list" command with the given environment name and returns the output as a string, returning an error if the command fails.
func (*CLI) RecipeRegister ¶
func (cli *CLI) RecipeRegister(ctx context.Context, envName, recipeName, templateKind, templatePath, resourceType string, plainHTTP bool) (string, error)
RecipeRegister runs a command to register a recipe with the given environment, template kind, template path and resource type, and returns the output string or an error.
func (*CLI) RecipeShow ¶
func (cli *CLI) RecipeShow(ctx context.Context, envName, recipeName string, resourceType string) (string, error)
RecipeShow runs a command to show a recipe with the given environment name, recipe name and resource type, and returns the output string or an error.
func (*CLI) RecipeUnregister ¶
func (cli *CLI) RecipeUnregister(ctx context.Context, envName, recipeName, resourceType string) (string, error)
RecipeUnregister runs a command to unregister a recipe from an environment, given the recipe name and resource type. It returns a string and an error if the command fails.
func (*CLI) ReportCommandResult ¶
func (cli *CLI) ReportCommandResult(ctx context.Context, out string, description string, err error) error
ReportCommandResult can be used in tests to report the result of a command to the test infrastructure. Most test should use RunCommand. Only use ReportCommandResult if the test is using CreateCommand to control command execution.
func (*CLI) ResourceExpose ¶
func (cli *CLI) ResourceExpose(ctx context.Context, applicationName string, resourceName string, localPort int, remotePort int) (string, error)
ResourceExpose runs a command to expose a resource from an application on a given port.
func (*CLI) ResourceList ¶
ResourceList runs the "resource list containers" command with the given application name and returns the output as a string, returning an error if the command fails.
func (*CLI) ResourceLogs ¶
func (cli *CLI) ResourceLogs(ctx context.Context, applicationName string, resourceName string) (string, error)
ResourceLogs runs the CLI command to get the logs of a resource in an application.
func (*CLI) ResourceShow ¶
func (cli *CLI) ResourceShow(ctx context.Context, resourceType string, resourceName string) (string, error)
ResourceShow runs the rad resource show command with the given resource type and name and returns the output string or an error if the command fails.
func (*CLI) RunCommand ¶
RunCommand executes a command and returns the output (stdout + stderr) as well as an error if the command fails. The output is *ALWAYS* returned even if the command fails.
type CLIError ¶
type CLIError struct {
v1.ErrorResponse
}
func (*CLIError) Error ¶
CLIError.Error returns a string containing the error code and message of the error response.
func (*CLIError) GetFirstErrorCode ¶
GetFirstErrorCode function goes down the error chain to find and return the code of the first error in the chain.
type ValidateInput ¶
type ValidateInput struct { Name string Input []string ExpectedValid bool ConfigHolder framework.ConfigHolder ConfigureMocks func(mocks ValidateMocks) // ValidateCallback can be used to support a validation callback that will run after all other validation. // // This can be used to validate side-effects that occur in a Runner's Validate() function. ValidateCallback func(t *testing.T, runner framework.Runner) // CreateTempDirectory can be used to create a directory, and change directory into the // newly created directory before calling Validate. Set this field to the name of the directory // you want. The test framework will handle the cleanup. CreateTempDirectory string }
type ValidateMocks ¶
type ValidateMocks struct { Kubernetes *kubernetes.MockInterface Namespace *namespace.MockInterface Prompter *prompt.MockInterface Helm *helm.MockInterface ApplicationManagementClient *clients.MockApplicationsManagementClient AzureClient *azure.MockClient AWSClient *aws.MockClient }