plugintest

package
v0.0.0-...-2a7d404 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExampleSecretFromComposition

func ExampleSecretFromComposition(v schema.ValueComposition) string

func LoadFixture

func LoadFixture(t *testing.T, filename string) string

LoadFixture loads the test fixture file from the "test-fixtures" dir in the plugin directory. It fails the test if the file can't be loaded.

func PrintReportIfErrors

func PrintReportIfErrors(plugin schema.Plugin) (hasErrors bool)

func PrintValidationReport

func PrintValidationReport(plugin schema.Plugin)

func TestImporter

func TestImporter(t *testing.T, importer sdk.Importer, cases map[string]ImportCase)

TestImporter will run the importer for each specified case, mounting the specified files in a temp dir, setting the environment variables, and configuring the home path using the temp dir.

func TestNeedsAuth

func TestNeedsAuth(t *testing.T, rule sdk.NeedsAuthentication, cases map[string]NeedsAuthCase)

func TestProvisioner

func TestProvisioner(t *testing.T, provisioner sdk.Provisioner, cases map[string]ProvisionCase)

TestProvisioner will invoke the specified provisioner with the item fields specified in each test case, comparing the provisioner output with the specified expected output.

Types

type ImportCase

type ImportCase struct {
	// Environment can be used to set environment variables for the importer test.
	Environment map[string]string

	// Files can be used to set files for the importer test, using the format: path -> contents.
	// For example: ~/.config/my-pugin/config -> '{"foo":"bar"}'. This is useful in conjunction with the
	// LoadFixture helper.
	Files map[string]string

	// OS can be used to test OS-specific importers. Supported values: "darwin", "linux"
	OS string

	// ExpectedCandidates is a shorthand to set the expected import candidates. Mutually exclusive with ExpectedOutput.
	ExpectedCandidates []sdk.ImportCandidate

	// ExpectedOutput can be used to set the exact expected import output. Mutually exclusive with ExpectedCandidates.
	ExpectedOutput *sdk.ImportOutput
}

type NeedsAuthCase

type NeedsAuthCase struct {
	Args              []string
	ExpectedNeedsAuth bool
}

type PrintFormat

type PrintFormat struct {
	Heading *color.Color
	Warning *color.Color
	Error   *color.Color
	Success *color.Color
}

func (PrintFormat) ValidationReportFormat

func (pf PrintFormat) ValidationReportFormat() PrintFormat

type ProvisionCase

type ProvisionCase struct {
	// ItemFields can be used to populate the item fields to pass to the provisioner.
	ItemFields map[sdk.FieldName]string

	// CommandLine can be used to populate the command line to pass to the provisioner.
	CommandLine []string

	// ExpectedOutput can be used to set the exact expected provision output, which contains the
	// environment, files, and command line.
	ExpectedOutput sdk.ProvisionOutput
}

type ValidationReportPrinter

type ValidationReportPrinter struct {
	Reports []schema.ValidationReport
	Format  PrintFormat
}

func (*ValidationReportPrinter) Print

func (p *ValidationReportPrinter) Print()

func (*ValidationReportPrinter) PrintReport

func (p *ValidationReportPrinter) PrintReport(report schema.ValidationReport)

Jump to

Keyboard shortcuts

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