dummy

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MockSecretValue = "MockSecretValue"
)

Variables

View Source
var MockSecretID = secrets.MustParseID("MockSecretID")

Functions

func CreateDummyPlugins

func CreateDummyPlugins(t *testing.T, cfg Plugins) string

CreateDummyPlugins Use it in a test to create a set of dummy plugins that behave like normal plugins but under the hood re-use the test binary. This is the counterpart to dummyPluginProcessFromBinaryName().

func PluginCommand

func PluginCommand(t *testing.T, cfg PluginCfg) (*exec.Cmd, func() (*PluginResult, error))

PluginCommand can be called from within tests. The returned *exec.Cmd runs the PluginProcess() that implements the plugin.Plugin interface, i.e., we get a normal external plugin binary. Under the hood, it re-runs the existing test binary (created by go test) with different parameters. The TestMain acts as a switch to then instead running as normal test to run PluginProcess().

func PluginProcess

func PluginProcess(cfg *PluginCfg)

PluginProcess is the equivalent of a main when normally implementing a plugin. Here, it gets run by TestMain if PluginCommand is used to re-launch the test binary (the binary built by go test).

func PluginProcessFromBinaryName

func PluginProcessFromBinaryName(name string)

PluginProcessFromBinaryName configures and runs a dummy plugin process. To be used from TestMain.

Types

type CrashBehaviour

type CrashBehaviour struct {
	OnNthSecretRequest int `json:"on_nth_secret_request"`
	ExitCode           int `json:"exit_code"`
}

type PluginBehaviour

type PluginBehaviour struct {
	Value string `json:"value"`
	*CrashBehaviour
}

func ParsePluginBehaviour

func ParsePluginBehaviour(s string) (PluginBehaviour, error)

func (PluginBehaviour) ToString

func (p PluginBehaviour) ToString() (string, error)

type PluginCfg

type PluginCfg struct {
	Version        string            `json:"version"`
	Pattern        string            `json:"pattern"`
	Secrets        map[string]string `json:"secrets"`
	ErrGetSecret   string            `json:"errGetSecret,omitempty"`
	IgnoreSigint   bool              `json:"ignoreSigint,omitempty"`
	ErrConfigPanic string            `json:"errConfigPanic,omitempty"`
	*CrashBehaviour
}

type PluginResult

type PluginResult struct {
	GetSecret    []string
	Log          string
	ErrTestSetup string
}

type Plugins

type Plugins struct {
	FailPlugin bool
	Plugins    []PluginBehaviour
}

Jump to

Keyboard shortcuts

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