Documentation ¶
Index ¶
- Variables
- func AddSuffixToFileName(fileName string, suffix string) string
- func CreateTempDir(subdir string) string
- func GetBinaryDecision() bool
- func GetDevFileName() string
- func GetRandomDecision(success int, failure int) bool
- func GetRandomGroupKind() schema.CommandGroupKind
- func GetRandomNumber(min int, max int) int
- func GetRandomString(n int, lower bool) string
- func GetRandomUniqueString(n int, lower bool) string
- func LogErrorMessage(message string) string
- func LogInfoMessage(message string) string
- func LogMessage(message string) string
- type DevfileFollower
- type DevfileValidator
- type TestContent
- type TestDevfile
- func (testDevFile *TestDevfile) AddCommand(commandType schema.CommandType) schema.Command
- func (devfile *TestDevfile) AddComponent(componentType schema.ComponentType) schema.Component
- func (devfile *TestDevfile) AddEvents() schema.Events
- func (testDevfile *TestDevfile) AddProject(projectType schema.ProjectSourceType) string
- func (testDevfile *TestDevfile) AddStarterProject(projectType schema.ProjectSourceType) string
- func (devfile *TestDevfile) CreateEndpoints() []schema.Endpoint
- func (devfile *TestDevfile) EventsAdded(events *schema.Events)
- func (devfile *TestDevfile) EventsUpdated(events *schema.Events)
- func (devfile *TestDevfile) GetContainerName() string
- func (testDevfile *TestDevfile) RunTest(testContent TestContent, t *testing.T)
- func (testDevFile *TestDevfile) SetApplyCommandValues(command *schema.Command)
- func (testDevFile *TestDevfile) SetCompositeCommandCommands(command *schema.Command, commandType schema.CommandType)
- func (testDevFile *TestDevfile) SetCompositeCommandValues(command *schema.Command)
- func (devfile *TestDevfile) SetContainerComponentValues(component *schema.Component)
- func (devfile *TestDevfile) SetEventsValues(events *schema.Events)
- func (testDevFile *TestDevfile) SetExecCommandValues(command *schema.Command)
- func (testDevfile *TestDevfile) SetProjectValues(project *schema.Project)
- func (testDevfile *TestDevfile) SetStarterProjectValues(starterProject *schema.StarterProject)
- func (devfile *TestDevfile) SetVolumeComponentValues(component *schema.Component)
Constants ¶
This section is empty.
Variables ¶
var Exposures = [...]schema.EndpointExposure{schema.PublicEndpointExposure, schema.InternalEndpointExposure, schema.NoneEndpointExposure}
var GroupKinds = [...]schema.CommandGroupKind{schema.BuildCommandGroupKind, schema.RunCommandGroupKind, schema.TestCommandGroupKind, schema.DebugCommandGroupKind}
var Protocols = [...]schema.EndpointProtocol{schema.HTTPEndpointProtocol, schema.HTTPSEndpointProtocol, schema.WSEndpointProtocol, schema.WSSEndpointProtocol, schema.TCPEndpointProtocol, schema.UDPEndpointProtocol}
var StringCount int = 0
Functions ¶
func AddSuffixToFileName ¶
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 ¶
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 ¶
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 ¶
GetRandomNumber randomly returns an integer between 1 and the number specified.
func GetRandomString ¶
GetRandomString returns a random string which is n characters long. If lower is set to true a lower case string is returned.
func GetRandomUniqueString ¶
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 LogErrorMessage ¶
LogErrorMessage logs the specified message as an error message and returns the message logged
func LogInfoMessage ¶
LogInfoMessage logs the specified message as an info message and returns the message logged
func LogMessage ¶
LogMessage logs the specified 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 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) 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) 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) 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) 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