testutil

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: EPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WorkspaceTemplateDiffOpts = cmp.Options{
	cmpopts.SortSlices(func(a, b dw.Component) bool {
		return strings.Compare(a.Key(), b.Key()) > 0
	}),
	cmpopts.SortSlices(func(a, b string) bool {
		return strings.Compare(a, b) > 0
	}),

	cmpopts.IgnoreFields(dw.DevWorkspaceEvents{}, "PostStart", "PreStop", "PostStop"),
}

Functions

func SetupControllerCfg

func SetupControllerCfg()

Types

type FakeHTTPGetter

type FakeHTTPGetter struct {
	DevfileResources      map[string]dw.Devfile
	DevWorkspaceResources map[string]dw.DevWorkspaceTemplate
	Errors                map[string]TestPluginError
}

func (*FakeHTTPGetter) Get

func (reg *FakeHTTPGetter) Get(location string) (*http.Response, error)

type FakeInternalRegistry

type FakeInternalRegistry struct {
	Plugins map[string]dw.DevWorkspaceTemplate
	Errors  map[string]TestPluginError
}

func (*FakeInternalRegistry) IsInInternalRegistry

func (reg *FakeInternalRegistry) IsInInternalRegistry(pluginID string) bool

func (*FakeInternalRegistry) ReadPluginFromInternalRegistry

func (reg *FakeInternalRegistry) ReadPluginFromInternalRegistry(pluginID string) (*dw.DevWorkspaceTemplate, error)

type FakeK8sClient

type FakeK8sClient struct {
	client.Client         // To satisfy interface; override all used methods
	DevWorkspaceResources map[string]dw.DevWorkspaceTemplate
	Errors                map[string]TestPluginError
}

func (*FakeK8sClient) Get

func (client *FakeK8sClient) Get(_ context.Context, namespacedName client.ObjectKey, obj runtime.Object) error

type TestCase

type TestCase struct {
	Name   string     `json:"name"`
	Input  TestInput  `json:"input"`
	Output TestOutput `json:"output"`
}

func LoadAllTestsOrPanic

func LoadAllTestsOrPanic(t *testing.T, fromDir string) []TestCase

func LoadTestCaseOrPanic

func LoadTestCaseOrPanic(t *testing.T, testFilepath string) TestCase

type TestInput

type TestInput struct {
	DevWorkspace *dw.DevWorkspaceTemplateSpec `json:"devworkspace,omitempty"`
	// DevWorkspaceResources is a map of string keys to devworkspace templates
	DevWorkspaceResources map[string]dw.DevWorkspaceTemplate `json:"devworkspaceResources,omitempty"`
	// DevfileResources is a map of string keys to devfile resources
	DevfileResources map[string]dw.Devfile `json:"devfileResources,omitempty"`
	// Errors is a map of plugin name to the error that should be returned when attempting to retrieve it.
	Errors map[string]TestPluginError `json:"errors,omitempty"`
}

type TestOutput

type TestOutput struct {
	DevWorkspace *dw.DevWorkspaceTemplateSpec `json:"devworkspace,omitempty"`
	ErrRegexp    *string                      `json:"errRegexp,omitempty"`
}

type TestPluginError

type TestPluginError struct {
	// IsNotFound marks this error as a kubernetes NotFoundError
	IsNotFound bool `json:"isNotFound"`
	// StatusCode defines the HTTP response code (if relevant)
	StatusCode int `json:"statusCode"`
	// Message is the error message returned
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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