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(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 TestDevfile
- func (devfile *TestDevfile) AddCommand(commandType schema.CommandType) schema.Command
- func (devfile *TestDevfile) AddComponent(componentType schema.ComponentType) schema.Component
- func (devfile *TestDevfile) CreateEndpoints() []schema.Endpoint
- func (devfile *TestDevfile) EditCommands() error
- func (devfile *TestDevfile) EditComponents() error
- func (devfile *TestDevfile) GetContainerName() string
- func (devfile *TestDevfile) UpdateCommand(commandId string) error
- func (devfile *TestDevfile) UpdateComponent(componentName string) error
- func (devfile *TestDevfile) Verify() error
- func (devfile *TestDevfile) VerifyCommands(parserCommands []schema.Command) error
- func (devfile *TestDevfile) VerifyComponents(parserComponents []schema.Component) error
- func (devfile *TestDevfile) WriteDevfile(useParser bool) error
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.WSEndpointProtocol, schema.TCPEndpointProtocol, schema.UDPEndpointProtocol}
var Protocols = [...]schema.EndpointProtocol{schema.HTTPEndpointProtocol, schema.HTTPSEndpointProtocol, schema.WSEndpointProtocol, schema.WSSEndpointProtocol, schema.TCPEndpointProtocol, schema.UDPEndpointProtocol}
var RndSeed int64 = time.Now().UnixNano()
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 TestDevfile ¶
type TestDevfile struct {
SchemaDevFile schema.Devfile
FileName string
ParserData devfileData.DevfileData
SchemaParsed bool
GroupDefaults map[schema.CommandGroupKind]bool
UsedPorts map[int]bool
}
TestDevfile is a structure used to track a test devfile and its contents
func GetDevfile ¶
func GetDevfile(fileName string) (TestDevfile, error)
GetDevfile returns a structure used to represent a specific devfile in a test
func (*TestDevfile) AddCommand ¶
func (devfile *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) CreateEndpoints ¶
func (devfile *TestDevfile) CreateEndpoints() []schema.Endpoint
CreateEndpoints creates and returns a randon number of endpoints in a schema structure
func (*TestDevfile) EditCommands ¶
func (devfile *TestDevfile) EditCommands() error
EditCommands modifies random attributes for each of the commands in the devfile.
func (*TestDevfile) EditComponents ¶
func (devfile *TestDevfile) EditComponents() error
EditComponents modifies random attributes for each of the components in the devfile.
func (*TestDevfile) GetContainerName ¶
func (devfile *TestDevfile) GetContainerName() string
GetContainer returns the name of an existing, or newly created, container.
func (*TestDevfile) UpdateCommand ¶
func (devfile *TestDevfile) UpdateCommand(commandId string) error
UpdateCommand randomly updates attribute values of a specified command in the devfile schema
func (*TestDevfile) UpdateComponent ¶
func (devfile *TestDevfile) UpdateComponent(componentName string) error
UpdateComponent randomly updates the attribute values of a specified component
func (*TestDevfile) Verify ¶
func (devfile *TestDevfile) Verify() error
Verify verifies the contents of the specified devfile with the expected content
func (*TestDevfile) VerifyCommands ¶
func (devfile *TestDevfile) VerifyCommands(parserCommands []schema.Command) error
VerifyCommands verifies commands returned by the parser are the same as those saved in the devfile schema
func (*TestDevfile) VerifyComponents ¶
func (devfile *TestDevfile) VerifyComponents(parserComponents []schema.Component) error
VerifyComponents verifies components returned by the parser are the same as those saved in the devfile schema
func (*TestDevfile) WriteDevfile ¶
func (devfile *TestDevfile) WriteDevfile(useParser bool) error
WriteDevfile create a devifle on disk for use in a test. If useParser is true the parser library is used to generate the file, otherwise "sigs.k8s.io/yaml" is used.