common

package
v2.0.0-...-01444cd Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: EPL-2.0 Imports: 13 Imported by: 0

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 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

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

Jump to

Keyboard shortcuts

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