pluginapitester

package
v2.107.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 21 Imported by: 6

Documentation

Overview

Package pluginapitester provides functions that simulate invoking a plugin from gödel. Can be used to test plugin implementations in plugin projects.

Package pluginapitester provides functions that simulate invoking a plugin from gödel. Can be used to test plugin implementations in plugin projects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunPlugin

func RunPlugin(
	pluginProvider PluginProvider,
	assetProviders []AssetProvider,
	taskName string,
	args []string,
	projectDir string,
	debug bool,
	stdout io.Writer) (cleanup func(), rErr error)

RunPlugin runs a plugin with the specified arguments. The plugin is loaded in the same manner that it would be for gödel itself. RunPlugin is equivalent to calling "./godelw [taskName] [args]" where "godelw" is in "projectDir". Note that this call does not change the working directory, so any arguments that take relative paths should take that into account. If "debug" is true, then it is the equivalent of calling "./godelw --debug [taskName] [args]". If the project directory does not contain a file named "godelw", this function creates the path. The returned "cleanup" function removes the "godelw" file if it was created by this function and is suitable to defer.

func RunUpgradeConfig

func RunUpgradeConfig(
	pluginProvider PluginProvider,
	assetProviders []AssetProvider,
	legacy bool,
	projectDir string,
	debug bool,
	stdout io.Writer) (cleanup func(), rErr error)

RunUpgradeConfig runs the "upgrade-config" task with the provided plugin and assets loaded. The plugin is loaded in the same manner that it would be for gödel itself. RunPlugin is mostly equivalent to calling "./godelw upgrade-config" where "godelw" is in "projectDir". The one difference is that the "upgrade-config" task will only run the upgrade task provided by the plugin (it will not run any builtin config upgrades). If "debug" is true, then it is the equivalent of calling "./godelw --debug upgrade-config". If the project directory does not contain a file named "godelw", this function creates the path. The returned "cleanup" function removes the "godelw" file if it was created by this function and is suitable to defer. Returns an error if the specified plugin does not provide a config upgrader.

func RunUpgradeConfigTest

func RunUpgradeConfigTest(t *testing.T,
	pluginProvider PluginProvider,
	assetProviders []AssetProvider,
	testCases []UpgradeConfigTestCase,
)

RunUpgradeConfigTest tests the "upgrade-config" operation using the provided plugin and assets. Resolves the plugin using the provided locator and resolver, provides it with the assets and invokes the "upgrade-config" command.

Types

type AssetProvider

type AssetProvider interface {
	AssetFilePath() string
}

func NewAssetProvider

func NewAssetProvider(assetPath string) AssetProvider

func NewAssetProviderFromLocator

func NewAssetProviderFromLocator(assetLocator, assetResolver string) (AssetProvider, error)

type PluginProvider

type PluginProvider interface {
	PluginFilePath() string
}

func NewPluginProvider

func NewPluginProvider(pluginPath string) PluginProvider

func NewPluginProviderFromLocator

func NewPluginProviderFromLocator(pluginLocator, pluginResolver string) (PluginProvider, error)

type UpgradeConfigTestCase

type UpgradeConfigTestCase struct {
	Name        string
	ConfigFiles map[string]string
	Legacy      bool
	WantError   bool
	WantOutput  string
	WantFiles   map[string]string
}

Jump to

Keyboard shortcuts

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