testingutil

package
v0.0.0-...-8dda575 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupEnv

func CleanupEnv(confFiles []*os.File, t *testing.T)

CleanupEnv cleans up the mock config file and anything that SetupEnv generated Parameters:

configFile: the mock config file handler
t: testing pointer to log errors if any

func FakeClusterServiceClass

func FakeClusterServiceClass(name string, tags ...string) v1beta1.ClusterServiceClass

FakeClusterServiceClass creates a fake service class with the specified name for testing purposes

func FakeClusterServicePlan

func FakeClusterServicePlan(name string, planNumber int) v1beta1.ClusterServicePlan

FakeClusterServicePlan creates a fake plan with the specified external name and using planNumber to customize description, metadata and parameter values

func FakeDeploymentConfigs

func FakeDeploymentConfigs() *v1.DeploymentConfigList

func FakeImageStreamTags

func FakeImageStreamTags(imageName string, namespace string, tags []string, hiddenTags []string) *imagev1.ImageStreamTagList

FakeImageStreamTags lists the imagestreams for the reactor

func FakeImageStreams

func FakeImageStreams(imageName string, namespace string, tags []string) *imagev1.ImageStreamList

FakeImageStreams lists the imagestreams for the reactor

func FakeKubeClientConfig

func FakeKubeClientConfig() string

FakeKubeClientConfig returns mock kube client config

func FakeOdoConfig

func FakeOdoConfig(confPath string, needNamePrefix bool, namePrefix string) preference.PreferenceInfo

FakeOdoConfig returns mock odo config It takes a confPath which is the path to the config

func FakeOnlyOneExistingProjects

func FakeOnlyOneExistingProjects() *v1.ProjectList

FakeOnlyOneExistingProjects returns fake projectlist with single project for use by API mock functions for Unit tests testing delete of the only available project

func FakePVC

func FakePVC(pvcName, size string, labels map[string]string) *corev1.PersistentVolumeClaim

func FakePlanInstanceCreateParameterSchemasRaw

func FakePlanInstanceCreateParameterSchemasRaw() [][]byte

FakePlanInstanceCreateParameterSchemasRaw creates 2 create parameter schemas for testing purposes

func FakeProjectStatus

func FakeProjectStatus(prjStatus corev1.NamespacePhase, prjName string) *projectv1.Project

FakeProjectStatus returns fake project status for use by mock watch on project

func FakeProjects

func FakeProjects() *v1.ProjectList

FakeProjects returns fake projectlist for use by API mock functions for Unit tests

func FakeRemoveProject

func FakeRemoveProject(project string, projects *v1.ProjectList) *v1.ProjectList

FakeRemoveProject removes the delete requested project from the list of projects passed

func FakeServiceClassInstance

func FakeServiceClassInstance(serviceInstanceName string, serviceClassName string, planName string, status string) scv1beta1.ServiceInstance

FakeServiceClassInstance creates and returns a simple service class instance for testing purpose serviceInstanceName is the name of the service class instance serviceClassName is the name of the service class planName is the name of the plan status is the status of the service instance

func OneFakeDeploymentConfigWithMounts

func OneFakeDeploymentConfigWithMounts(componentName, componentType, applicationName string, mountedStorage map[string]*corev1.PersistentVolumeClaim) *v1.DeploymentConfig

mountedStorage is the map of the storage to be mounted key is the path for the mount, value is the pvc

func RunPromptTest

func RunPromptTest(t *testing.T, test PromptTest)

RunPromptTest runs the specified PromptTest in the given testing context

func RunTest

func RunTest(t *testing.T, procedure func(*expect.Console), test func(terminal.Stdio) error)

RunTest runs the given test using the specified procedure simulating the user interaction with the console

func SetUp

func SetUp(odoConfigDetails ConfigDetails, kubeConfigDetails ConfigDetails) (*os.File, *os.File, error)

SetUp sets up the odo and kube config files and returns respective conf file pointers and error

func SimulateFileModifications

func SimulateFileModifications(basePath string, fileModification FileProperties) (string, error)

SimulateFileModifications mock function to simulate requested file/folder operation Parameters:

basePath: The parent directory for file/folder involved in desired file operation
fileModification: Meta-data of file/folder

Returns:

path to file/folder involved in the operation
error if any or nil

func SingleValuedRawExtension

func SingleValuedRawExtension(name, value string) *runtime.RawExtension

SingleValuedRawExtension creates a simple, single valued (name=value), raw extension

func Stdio

func Stdio(c *expect.Console) terminal.Stdio

Stdio converts an expect.Console into a survey terminal.Stdio

func TempMkFile

func TempMkFile(dir string, fileName string) (string, error)

TempMkFile creates a temporary file.

func TempMkdir

func TempMkdir(parentDir string, newDirPrefix string) (string, error)

TempMkdir creates a temporary directory

Types

type ConfigDetails

type ConfigDetails struct {
	FileName      string
	Config        interface{}
	ConfigPathEnv string
}

ConfigDetails struct holds configuration details(odo and/or kube config)

type FileProperties

type FileProperties struct {
	FilePath         string
	FileParent       string
	FileType         FileType
	ModificationType ModificationType
}

FileProperties to contain meta-data of a file like, file/folder name, file/folder parent dir, file type and desired file modification type

type FileType

type FileType int

FileType custom type to indicate type of file

const (
	// RegularFile enum to represent regular file
	RegularFile FileType = 0
	// Directory enum to represent directory
	Directory FileType = 1
)

type M

type M map[string]interface{}

M is an alias for map[string]interface{}

type ModificationType

type ModificationType string

ModificationType custom type to indicate file modification type

const (
	// UPDATE enum representing update operation on a file
	UPDATE ModificationType = "update"
	// CREATE enum representing create operation for a file/folder
	CREATE ModificationType = "create"
	// DELETE enum representing delete operation for a file/folder
	DELETE ModificationType = "delete"
	// APPEND enum representing append operation on a file
	APPEND ModificationType = "append"
)

type PromptTest

type PromptTest struct {
	// Name of the test
	Name string
	// Prompt to test
	Prompt survey.Prompt
	// Procedure defines the list of interaction with the console simulating user actions
	Procedure func(*expect.Console)
	// Expected result
	Expected interface{}
}

PromptTest encapsulates a survey prompt test

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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