common

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StringCount int = 0

Functions

func AddSuffixToFileName

func AddSuffixToFileName(fileName string, suffix string) string

AddSuffixToFileName adds a specified suffix to the name of a specified file. For example if the file is devfile.yaml and the suffix is 1, the result is devfile1.yaml

func CreateTempDir

func CreateTempDir(subdir string) string

CreateTempDir creates a specified sub directory under the temp directory if it does not exist. Returns the name of the created directory.

func GetBinaryDecision

func GetBinaryDecision() bool

GetBinaryDecision randomly returns true or false

func GetDevFileName

func GetDevFileName() string

GetDevFileName returns a qualified name of a devfile for use in a test. The devfile will be in a temporary directory and is named using the calling function's name.

func GetRandomDecision

func GetRandomDecision(success int, failure int) bool

GetRandomDecision randomly returns true or false, but weighted to one or the other. For example if success is set to 2 and failure to 1, true is twice as likely to be returned.

func GetRandomGroupKind

func GetRandomGroupKind() schema.CommandGroupKind

GetRandomGroupKind return random group kind. One of "build", "run", "test" or "debug"

func GetRandomNumber

func GetRandomNumber(min int, max int) int

GetRandomNumber randomly returns an integer between 1 and the number specified.

func GetRandomString

func GetRandomString(n int, lower bool) string

GetRandomString returns a random string which is n characters long. If lower is set to true a lower case string is returned.

func GetRandomUniqueString

func GetRandomUniqueString(n int, lower bool) string

GetRandomUniqueString returns a unique random string which is n characters long plus an integer to ensure uniqueness If lower is set to true a lower case string is returned.

func GetRandomValue added in v2.2.0

func GetRandomValue(typedConstants interface{}) reflect.Value

func LogErrorMessage

func LogErrorMessage(message string) string

LogErrorMessage logs the specified message as an error message and returns the message logged

func LogInfoMessage

func LogInfoMessage(message string) string

LogInfoMessage logs the specified message as an info message and returns the message logged

func LogMessage

func LogMessage(message string) string

LogMessage logs the specified message and returns the message logged

func LogWarningMessage added in v2.2.0

func LogWarningMessage(message string) string

LogWarningMessage logs the specified message as a warning message and returns the message logged

Types

type DevfileFollower

type DevfileFollower interface {
	AddCommand(schema.Command) error
	UpdateCommand(schema.Command)
	AddComponent(schema.Component) error
	UpdateComponent(schema.Component)
	AddProject(schema.Project) error
	UpdateProject(schema.Project)
	AddStarterProject(schema.StarterProject) error
	UpdateStarterProject(schema.StarterProject)
	AddEvent(schema.Events) error
	UpdateEvent(schema.Events)
	SetParent(schema.Parent) error
	UpdateParent(schema.Parent)

	SetMetaData(header.DevfileMetadata) error
	UpdateMetaData(header.DevfileMetadata)
	SetSchemaVersion(string)
}

DevfileFollower interface implemented by the parser tests for updating the parser data

type DevfileValidator

type DevfileValidator interface {
	WriteAndValidate(*TestDevfile) error
}

DevfileValidator interface implemented by the parser and api tests for verifying generated devfiles

type TestContent

type TestContent struct {
	CommandTypes        []schema.CommandType
	ComponentTypes      []schema.ComponentType
	ProjectTypes        []schema.ProjectSourceType
	StarterProjectTypes []schema.ProjectSourceType
	AddParent           bool
	AddMetaData         bool
	AddEvents           bool
	FileName            string
	EditContent         bool
}

TestContent - structure used by a test to configure the tests to run

type TestDevfile

type TestDevfile struct {
	SchemaDevFile schema.Devfile
	FileName      string
	GroupDefaults map[schema.CommandGroupKind]bool
	UsedPorts     map[int]bool
	Follower      DevfileFollower
	Validator     DevfileValidator
}

TestDevfile is a structure used to track a test devfile and its contents

func GetDevfile

func GetDevfile(fileName string, follower DevfileFollower, validator DevfileValidator) (TestDevfile, error)

GetDevfile returns a structure used to represent a specific devfile in a test

func (*TestDevfile) AddCommand

func (testDevFile *TestDevfile) AddCommand(commandType schema.CommandType) schema.Command

AddCommand creates a command of a specified type in a schema structure and pupulates it with random attributes

func (*TestDevfile) AddComponent

func (devfile *TestDevfile) AddComponent(componentType schema.ComponentType) schema.Component

AddComponent adds a component of the specified type, with random attributes, to the devfile schema

func (*TestDevfile) AddEvents

func (devfile *TestDevfile) AddEvents() schema.Events

AddEvents adds events in the test schema structure and populates it with random attributes

func (*TestDevfile) AddMetaData added in v2.2.0

func (devfile *TestDevfile) AddMetaData() header.DevfileMetadata

AddMetadata populates the metadata object with random attributes

func (*TestDevfile) AddParent added in v2.2.0

func (devfile *TestDevfile) AddParent() schema.Parent

AddParent adds properties in the test schema structure and populates it with random attributes

func (*TestDevfile) AddParentCommand added in v2.2.0

func (testDevFile *TestDevfile) AddParentCommand(commandType schema.CommandType) schema.CommandParentOverride

AddParentCommand creates a command of a specified type in a schema structure and populates it with random values

func (*TestDevfile) AddParentComponent added in v2.2.0

func (devfile *TestDevfile) AddParentComponent(componentType schema.ComponentType) schema.ComponentParentOverride

AddParentComponent adds a component of the specified type, with random attributes, to the devfile schema

func (*TestDevfile) AddParentProject added in v2.2.0

func (testDevfile *TestDevfile) AddParentProject(projectType schema.ProjectSourceType) string

AddParentProject adds a project of the specified type, with random attributes, to the devfile schema

func (*TestDevfile) AddParentStarterProject added in v2.2.0

func (testDevfile *TestDevfile) AddParentStarterProject(projectType schema.ProjectSourceType) string

AddParentStarterProject adds a starter project of the specified type, with random attributes, to the devfile schema

func (*TestDevfile) AddProject

func (testDevfile *TestDevfile) AddProject(projectType schema.ProjectSourceType) string

AddProject adds a project of the specified type, with random attributes, to the devfile schema

func (*TestDevfile) AddStarterProject

func (testDevfile *TestDevfile) AddStarterProject(projectType schema.ProjectSourceType) string

AddStarterProject adds a starter project of the specified type, with random attributes, to the devfile schema

func (*TestDevfile) CreateEndpoints

func (devfile *TestDevfile) CreateEndpoints() []schema.Endpoint

CreateEndpoints creates and returns a randon number of endpoints in a schema structure

func (*TestDevfile) CreateParentEndpoints added in v2.2.0

func (devfile *TestDevfile) CreateParentEndpoints() []schema.EndpointParentOverride

CreateParentEndpoints creates and returns a random number of endpoints in a schema structure

func (*TestDevfile) EventsAdded

func (devfile *TestDevfile) EventsAdded(events *schema.Events)

EventsAdded adds event to the test schema and notifies a registered follower

func (*TestDevfile) EventsUpdated

func (devfile *TestDevfile) EventsUpdated(events *schema.Events)

EventsUpdated notifies a registered follower that the events have been updated

func (*TestDevfile) GetContainerName

func (devfile *TestDevfile) GetContainerName() string

GetContainer returns the name of an existing, or newly created, container.

func (*TestDevfile) GetParentContainerName added in v2.2.0

func (devfile *TestDevfile) GetParentContainerName() string

GetParentContainerName returns the name of an existing, or newly created, container.

func (*TestDevfile) MetaDataAdded added in v2.2.0

func (devfile *TestDevfile) MetaDataAdded(metadata *header.DevfileMetadata)

MetadataAdded notifies a registered follower

func (*TestDevfile) MetaDataUpdated added in v2.2.0

func (devfile *TestDevfile) MetaDataUpdated(metadata *header.DevfileMetadata)

MetaDataUpdated notifies a registered follower that the metadata has been updated

func (*TestDevfile) ParentAdded added in v2.2.0

func (devfile *TestDevfile) ParentAdded(parent *schema.Parent)

ParentAdded adds the parent obj to the test schema

func (*TestDevfile) RunTest

func (testDevfile *TestDevfile) RunTest(testContent TestContent, t *testing.T)

Runs a test to create and verify a devfile based on the content of the specified TestContent

func (*TestDevfile) SetApplyCommandValues

func (testDevFile *TestDevfile) SetApplyCommandValues(command *schema.Command)

SetApplyCommandValues randomly sets/updates apply command attributes to random values

func (*TestDevfile) SetCompositeCommandCommands

func (testDevFile *TestDevfile) SetCompositeCommandCommands(command *schema.Command, commandType schema.CommandType)

SetCompositeCommandCommands set the commands in a composite command to a specific type

func (*TestDevfile) SetCompositeCommandValues

func (testDevFile *TestDevfile) SetCompositeCommandValues(command *schema.Command)

SetCompositeCommandValues randomly sets/updates composite command attributes to random values

func (*TestDevfile) SetContainerComponentValues

func (devfile *TestDevfile) SetContainerComponentValues(component *schema.Component)

SetContainerComponentValues randomly sets/updates container component attributes to random values

func (*TestDevfile) SetEventsValues

func (devfile *TestDevfile) SetEventsValues(events *schema.Events)

SetEventsValues randomly adds/modifies attributes of the supplied events

func (*TestDevfile) SetExecCommandValues

func (testDevFile *TestDevfile) SetExecCommandValues(command *schema.Command)

SetExecCommandValues randomly sets/updates exec command attributes to random values

func (*TestDevfile) SetK8sComponentValues added in v2.2.0

func (devfile *TestDevfile) SetK8sComponentValues(component *schema.Component)

SetK8sComponentValues randomly sets the required properties of a Kubernetes or Openshift component

func (*TestDevfile) SetParentApplyCommandValues added in v2.2.0

func (testDevFile *TestDevfile) SetParentApplyCommandValues(command *schema.CommandParentOverride)

SetApplyCommandValues randomly sets/updates apply command attributes to random values

func (*TestDevfile) SetParentCompositeCommandValues added in v2.2.0

func (testDevFile *TestDevfile) SetParentCompositeCommandValues(command *schema.CommandParentOverride)

SetParentCompositeCommandValues randomly sets/updates composite command attributes to random values

func (*TestDevfile) SetParentContainerComponentValues added in v2.2.0

func (devfile *TestDevfile) SetParentContainerComponentValues(component *schema.ComponentParentOverride)

SetParentContainerComponentValues randomly sets/updates container component attributes to random values

func (*TestDevfile) SetParentExecCommandValues added in v2.2.0

func (testDevFile *TestDevfile) SetParentExecCommandValues(command *schema.CommandParentOverride)

SetParentExecCommandValues randomly sets/updates exec command attributes to random values

func (*TestDevfile) SetParentK8sComponentValues added in v2.2.0

func (devfile *TestDevfile) SetParentK8sComponentValues(component *schema.ComponentParentOverride)

SetParentK8sComponentValues randomly sets the required properties of a Kubernetes or Openshift component

func (*TestDevfile) SetParentProjectValues added in v2.2.0

func (testDevfile *TestDevfile) SetParentProjectValues(project *schema.ProjectParentOverride)

SetParentProjectValues sets project attributes, common to all projects, to random values.

func (*TestDevfile) SetParentStarterProjectValues added in v2.2.0

func (testDevfile *TestDevfile) SetParentStarterProjectValues(starterProject *schema.StarterProjectParentOverride)

SetParentStarterProjectValues sets starter project attributes, common to all starter projects, to random values.

func (*TestDevfile) SetParentVolumeComponentValues added in v2.2.0

func (devfile *TestDevfile) SetParentVolumeComponentValues(component *schema.ComponentParentOverride)

SetParentVolumeComponentValues randomly sets/updates volume component attributes to random values

func (*TestDevfile) SetProjectValues

func (testDevfile *TestDevfile) SetProjectValues(project *schema.Project)

SetProjectValues sets project attributes, common to all projects, to random values.

func (*TestDevfile) SetStarterProjectValues

func (testDevfile *TestDevfile) SetStarterProjectValues(starterProject *schema.StarterProject)

SetStarterProjectValues sets starter project attributes, common to all starter projects, to random values.

func (*TestDevfile) SetVolumeComponentValues

func (devfile *TestDevfile) SetVolumeComponentValues(component *schema.Component)

SetVolumeComponentValues randomly sets/updates volume component attributes to random values

Jump to

Keyboard shortcuts

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