{"modulePath":"github.com/redhat-developer/Odo","version":"v1.2.6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testingutil\n\n## Functions\n\n```go\nfunc CleanupEnv(confFiles []*os.File, t *testing.T)\n```\nCleanupEnv cleans up the mock config file and anything that SetupEnv generated Parameters:\n\n\tconfigFile: the mock config file handler\n\tt: testing pointer to log errors if any\n\n```go\nfunc CreateFakeContainer(containerName string) corev1.Container\n```\nCreateFakeContainer creates a container with the given containerName\n\n```go\nfunc CreateFakeContainerWithVolumeMounts(containerName string, volumeMounts []corev1.VolumeMount) corev1.Container\n```\nCreateFakeContainerWithVolumeMounts creates a container with the given containerName and volumeMounts\n\n```go\nfunc CreateFakeDeployment(podName string) *appsv1.Deployment\n```\nCreateFakeDeployment creates a fake deployment with the given pod name and labels\n\n```go\nfunc CreateFakePod(componentName, podName string) *corev1.Pod\n```\nCreateFakePod creates a fake pod with the given pod name and component name\n\n```go\nfunc CreateFakePodWithContainers(componentName, podName string, containers []corev1.Container) *corev1.Pod\n```\nCreateFakePodWithContainers creates a fake pod with the given pod name, container name and containers\n\n```go\nfunc FakeClusterServiceClass(name string, tags ...string) v1beta1.ClusterServiceClass\n```\nFakeClusterServiceClass creates a fake service class with the specified name for testing purposes\n\n```go\nfunc FakeClusterServicePlan(name string, planNumber int) v1beta1.ClusterServicePlan\n```\nFakeClusterServicePlan creates a fake plan with the specified external name and using planNumber to customize description, metadata and parameter values\n\n```go\nfunc FakeDeploymentConfigs() *v1.DeploymentConfigList\n```\n\n```go\nfunc FakeImageStreamTags(imageName string, namespace string, tags []string, hiddenTags []string) *imagev1.ImageStreamTagList\n```\nFakeImageStreamTags lists the imagestreams for the reactor\n\n```go\nfunc FakeImageStreams(imageName string, namespace string, tags []string) *imagev1.ImageStreamList\n```\nFakeImageStreams lists the imagestreams for the reactor\n\n```go\nfunc FakeKubeClientConfig() string\n```\nFakeKubeClientConfig returns mock kube client config\n\n```go\nfunc FakeNamespaceStatus(status corev1.NamespacePhase, name string) *corev1.Namespace\n```\nFakeNamespaceStatus returns fake namespace status for use by mock watch on namespace\n\n```go\nfunc FakeNamespaces() *corev1.NamespaceList\n```\nFakeNamespaces returns fake namespace list for use by API mock functions for Unit tests\n\n```go\nfunc FakeOdoConfig(confPath string, needNamePrefix bool, namePrefix string) preference.PreferenceInfo\n```\nFakeOdoConfig returns mock odo config It takes a confPath which is the path to the config\n\n```go\nfunc FakeOnlyOneExistingNamespace() *corev1.NamespaceList\n```\nFakeOnlyOneExistingNamespace similar as FakeOnlyOneExistingProjects only with Namespace\n\n```go\nfunc FakeOnlyOneExistingProjects() *v1.ProjectList\n```\nFakeOnlyOneExistingProjects returns fake projectlist with single project for use by API mock functions for Unit tests testing delete of the only available project\n\n```go\nfunc FakePVC(pvcName, size string, labels map[string]string) *corev1.PersistentVolumeClaim\n```\n\n```go\nfunc FakePlanInstanceCreateParameterSchemasRaw() [][]byte\n```\nFakePlanInstanceCreateParameterSchemasRaw creates 2 create parameter schemas for testing purposes\n\n```go\nfunc FakePortListener(startedChan chan\u003c- bool, stopChan \u003c-chan bool, localPort int) error\n```\nFakePortListener starts a fake test server and listens on the given localPort\n\n```go\nfunc FakeProjectStatus(prjStatus corev1.NamespacePhase, prjName string) *projectv1.Project\n```\nFakeProjectStatus returns fake project status for use by mock watch on project\n\n```go\nfunc FakeProjects() *v1.ProjectList\n```\nFakeProjects returns fake projectlist for use by API mock functions for Unit tests\n\n```go\nfunc FakeRemoveProject(project string, projects *v1.ProjectList) *v1.ProjectList\n```\nFakeRemoveProject removes the delete requested project from the list of projects passed\n\n```go\nfunc FakeServiceClassInstance(serviceInstanceName string, serviceClassName string, planName string, status string) scv1beta1.ServiceInstance\n```\nFakeServiceClassInstance 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\n\n```go\nfunc GetFakeContainerComponent(name string) versionsCommon.DevfileComponent\n```\nGetFakeContainerComponent returns a fake container component for testing\n\n```go\nfunc GetFakeEnv(name, value string) versionsCommon.Env\n```\nGetFakeExecRunCommands returns a fake env for testing\n\n```go\nfunc GetFakeExecRunCommands() []versionsCommon.Exec\n```\nGetFakeExecRunCommands returns fake commands for testing\n\n```go\nfunc GetFakeVolume(name, size string) versionsCommon.Volume\n```\nGetFakeVolume returns a fake volume for testing\n\n```go\nfunc GetFakeVolumeComponent(name, size string) versionsCommon.DevfileComponent\n```\nGetFakeVolumeComponent returns a fake volume component for testing\n\n```go\nfunc GetFakeVolumeMount(name, path string) versionsCommon.VolumeMount\n```\nGetFakeVolumeMount returns a fake volume mount for testing\n\n```go\nfunc GetRouteListWithMultiple(componentName, applicationName string) *routev1.RouteList\n```\n\n```go\nfunc GetSingleRoute(urlName string, port int, componentName, applicationName string) routev1.Route\n```\n\n```go\nfunc MkFileWithContent(path, content string, fs filesystem.Filesystem) (string, error)\n```\n\n```go\nfunc OneFakeDeploymentConfigWithMounts(componentName, componentType, applicationName string, mountedStorage map[string]*corev1.PersistentVolumeClaim) *v1.DeploymentConfig\n```\nmountedStorage is the map of the storage to be mounted key is the path for the mount, value is the pvc\n\n```go\nfunc RunPromptTest(t *testing.T, test PromptTest)\n```\nRunPromptTest runs the specified PromptTest in the given testing context\n\n```go\nfunc RunTest(t *testing.T, procedure func(*expect.Console), test func(terminal.Stdio) error)\n```\nRunTest runs the given test using the specified procedure simulating the user interaction with the console\n\n```go\nfunc SetUp(odoConfigDetails ConfigDetails, kubeConfigDetails ConfigDetails) (*os.File, *os.File, error)\n```\nSetUp sets up the odo and kube config files and returns respective conf file pointers and error\n\n```go\nfunc SimulateFileModifications(basePath string, fileModification FileProperties) (string, error)\n```\nSimulateFileModifications mock function to simulate requested file/folder operation Parameters:\n\n\tbasePath: The parent directory for file/folder involved in desired file operation\n\tfileModification: Meta-data of file/folder\n\nReturns:\n\n\tpath to file/folder involved in the operation\n\terror if any or nil\n\n```go\nfunc SingleValuedRawExtension(name, value string) *runtime.RawExtension\n```\nSingleValuedRawExtension creates a simple, single valued (name=value), raw extension\n\n```go\nfunc Stdio(c *expect.Console) terminal.Stdio\n```\nStdio converts an expect.Console into a survey terminal.Stdio\n\n```go\nfunc TempMkFile(dir string, fileName string) (string, error)\n```\nTempMkFile creates a temporary file.\n\n```go\nfunc TempMkdir(parentDir string, newDirPrefix string) (string, error)\n```\nTempMkdir creates a temporary directory\n\n## Types\n\n```go\ntype ConfigDetails struct {\n\tFileName      string\n\tConfig        interface{}\n\tConfigPathEnv string\n}\n```\nConfigDetails struct holds configuration details(odo and/or kube config)\n\n```go\ntype FileProperties struct {\n\tFilePath         string\n\tFileParent       string\n\tFileType         FileType\n\tModificationType ModificationType\n}\n```\nFileProperties to contain meta-data of a file like, file/folder name, file/folder parent dir, file type and desired file modification type\n\n```go\ntype FileType int\n```\nFileType custom type to indicate type of file\n\n```go\nconst (\n\t// RegularFile enum to represent regular file\n\tRegularFile FileType = 0\n\t// Directory enum to represent directory\n\tDirectory FileType = 1\n)\n```\n\n```go\ntype M map[string]interface{}\n```\nM is an alias for map\\[string]interface{}\n\n```go\ntype ModificationType string\n```\nModificationType custom type to indicate file modification type\n\n```go\nconst (\n\t// UPDATE enum representing update operation on a file\n\tUPDATE ModificationType = \"update\"\n\t// CREATE enum representing create operation for a file/folder\n\tCREATE ModificationType = \"create\"\n\t// DELETE enum representing delete operation for a file/folder\n\tDELETE ModificationType = \"delete\"\n\t// APPEND enum representing append operation on a file\n\tAPPEND ModificationType = \"append\"\n)\n```\n\n```go\ntype PromptTest struct {\n\t// Name of the test\n\tName string\n\t// Prompt to test\n\tPrompt survey.Prompt\n\t// Procedure defines the list of interaction with the console simulating user actions\n\tProcedure func(*expect.Console)\n\t// Expected result\n\tExpected interface{}\n}\n```\nPromptTest encapsulates a survey prompt test\n\n```go\ntype TestDevfileData struct {\n\tComponents        []versionsCommon.DevfileComponent\n\tExecCommands      []versionsCommon.Exec\n\tCompositeCommands []versionsCommon.Composite\n\tCommands          map[string]versionsCommon.DevfileCommand\n\tEvents            common.DevfileEvents\n}\n```\nTestDevfileData is a convenience data type used to mock up a devfile configuration\n\n```go\nfunc (d *TestDevfileData) AddCommands(commands ...common.DevfileCommand) error\n```\n\n```go\nfunc (d TestDevfileData) AddComponents(components []common.DevfileComponent) error\n```\n\n```go\nfunc (d TestDevfileData) AddEvents(events common.DevfileEvents) error\n```\n\n```go\nfunc (d TestDevfileData) AddProjects(projects []common.DevfileProject) error\n```\n\n```go\nfunc (d TestDevfileData) AddStarterProjects(projects []common.DevfileStarterProject) error\n```\n\n```go\nfunc (d TestDevfileData) AddVolume(volume common.Volume, path string) error\n```\n\n```go\nfunc (d TestDevfileData) DeleteVolume(name string) error\n```\n\n```go\nfunc (d TestDevfileData) GetAliasedComponents() []versionsCommon.DevfileComponent\n```\nGetAliasedComponents is a mock function to get the components that have an alias from a devfile\n\n```go\nfunc (d *TestDevfileData) GetCommands() map[string]versionsCommon.DevfileCommand\n```\nGetCommands is a mock function to get the commands from a devfile\n\n```go\nfunc (d TestDevfileData) GetComponents() []versionsCommon.DevfileComponent\n```\nGetComponents is a mock function to get the components from a devfile\n\n```go\nfunc (d TestDevfileData) GetEvents() versionsCommon.DevfileEvents\n```\nGetEvents is a mock function to get events from devfile\n\n```go\nfunc (d TestDevfileData) GetMetadata() versionsCommon.DevfileMetadata\n```\nGetMetadata is a mock function to get metadata from devfile\n\n```go\nfunc (d TestDevfileData) GetParent() versionsCommon.DevfileParent\n```\nGetParent is a mock function to get parent from devfile\n\n```go\nfunc (d TestDevfileData) GetProjects() []versionsCommon.DevfileProject\n```\nGetProjects is a mock function to get the components that have an alias from a devfile\n\n```go\nfunc (d TestDevfileData) GetStarterProjects() []versionsCommon.DevfileStarterProject\n```\nGetStarterProjects returns the fake starter projects\n\n```go\nfunc (d TestDevfileData) GetVolumeMountPath(name string) (string, error)\n```\n\n```go\nfunc (d TestDevfileData) SetEvents(events common.DevfileEvents)\n```\n\n```go\nfunc (d TestDevfileData) SetMetadata(name, version string)\n```\nSetMetadata sets metadata for devfile\n\n```go\nfunc (d TestDevfileData) SetParent(parent common.DevfileParent)\n```\n\n```go\nfunc (d TestDevfileData) SetSchemaVersion(version string)\n```\nSetSchemaVersion sets schema version for devfile\n\n```go\nfunc (d TestDevfileData) UpdateCommand(command common.DevfileCommand)\n```\n\n```go\nfunc (d TestDevfileData) UpdateComponent(component common.DevfileComponent)\n```\n\n```go\nfunc (d TestDevfileData) UpdateEvents(postStart, postStop, preStart, preStop []string)\n```\n\n```go\nfunc (d TestDevfileData) UpdateProject(project common.DevfileProject)\n```\n\n```go\nfunc (d TestDevfileData) UpdateStarterProject(project common.DevfileStarterProject)\n```\n\n```go\nfunc (d TestDevfileData) Validate() error\n```\nValidate is a mock validation that always validates without error\n\n","path":"github.com/redhat-developer/Odo/pkg/testingutil","name":"testingutil","synopsis":"","isRedistributable":true}
