Documentation ¶
Overview ¶
Package scenariobuilder allows you to construct test scenarios which are based on executing the real todocheck binary against projects to use as scenarios.
Index ¶
- type TodoErrForJSON
- type TodoErrScenario
- func (s *TodoErrScenario) ExpectLine(line string) *TodoErrScenario
- func (s *TodoErrScenario) String() string
- func (s *TodoErrScenario) ToTodoErrForJSON() *TodoErrForJSON
- func (s *TodoErrScenario) WithJSONMetadata(metadata map[string]string) *TodoErrScenario
- func (s *TodoErrScenario) WithJSONMetadataEntry(key string, value string) *TodoErrScenario
- func (s *TodoErrScenario) WithLineNum(n int) *TodoErrScenario
- func (s *TodoErrScenario) WithLocation(source string, linenum int) *TodoErrScenario
- func (s *TodoErrScenario) WithSourceFile(sf string) *TodoErrScenario
- func (s *TodoErrScenario) WithType(t errors.TODOErrType) *TodoErrScenario
- type TodocheckScenario
- func (s *TodocheckScenario) DeleteTokensCacheAfter() *TodocheckScenario
- func (s *TodocheckScenario) ExpectExecutionError() *TodocheckScenario
- func (s *TodocheckScenario) ExpectOutputText(output string) *TodocheckScenario
- func (s *TodocheckScenario) ExpectTodoErr(sc *TodoErrScenario) *TodocheckScenario
- func (s *TodocheckScenario) OnlyRunOnCI() *TodocheckScenario
- func (s *TodocheckScenario) RequireAuthToken(token string) *TodocheckScenario
- func (s *TodocheckScenario) Run() error
- func (s *TodocheckScenario) SetOfflineTokenWhenRequested(token string) *TodocheckScenario
- func (s *TodocheckScenario) WithAuthTokenFromEnv(envVariable string) *TodocheckScenario
- func (s *TodocheckScenario) WithBasepath(basepath string) *TodocheckScenario
- func (s *TodocheckScenario) WithBinary(binaryLoc string) *TodocheckScenario
- func (s *TodocheckScenario) WithConfig(cfgPath string) *TodocheckScenario
- func (s *TodocheckScenario) WithEnvVariable(key, value string) *TodocheckScenario
- func (s *TodocheckScenario) WithGitConfig(origunURL string) *TodocheckScenario
- func (s *TodocheckScenario) WithIssue(issueID string, status issuetracker.Status) *TodocheckScenario
- func (s *TodocheckScenario) WithIssueTracker(issueTracker issuetracker.Type) *TodocheckScenario
- func (s *TodocheckScenario) WithJSONOutput() *TodocheckScenario
- func (s *TodocheckScenario) WithTestEnvConfig(cfgPath string) *TodocheckScenario
- func (s *TodocheckScenario) WithVersionFlag() *TodocheckScenario
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TodoErrForJSON ¶ added in v0.4.0
type TodoErrScenario ¶
type TodoErrScenario struct {
// contains filtered or unexported fields
}
TodoErrScenario encapsulates a test scenario for an expected todo err the program should return.
func (*TodoErrScenario) ExpectLine ¶
func (s *TodoErrScenario) ExpectLine(line string) *TodoErrScenario
ExpectLine appends an expected error line to the todo err scenario. more than one line can be specified.
func (*TodoErrScenario) String ¶
func (s *TodoErrScenario) String() string
func (*TodoErrScenario) ToTodoErrForJSON ¶ added in v0.4.0
func (s *TodoErrScenario) ToTodoErrForJSON() *TodoErrForJSON
func (*TodoErrScenario) WithJSONMetadata ¶ added in v0.5.0
func (s *TodoErrScenario) WithJSONMetadata(metadata map[string]string) *TodoErrScenario
WithJSONMetadata extends existing metadata with a multiple of key value pairs expected within the `metadata` field of the TODOs
func (*TodoErrScenario) WithJSONMetadataEntry ¶ added in v0.5.0
func (s *TodoErrScenario) WithJSONMetadataEntry(key string, value string) *TodoErrScenario
WithJSONMetadataEntry stores a single key-value pair that is expected in the `metadata` field
func (*TodoErrScenario) WithLineNum ¶
func (s *TodoErrScenario) WithLineNum(n int) *TodoErrScenario
WithLineNum specifies the expected starting line number for the given todo err scenario
func (*TodoErrScenario) WithLocation ¶
func (s *TodoErrScenario) WithLocation(source string, linenum int) *TodoErrScenario
WithLocation specifies the expected source file & line number for the given todo err scenario
func (*TodoErrScenario) WithSourceFile ¶
func (s *TodoErrScenario) WithSourceFile(sf string) *TodoErrScenario
WithSourceFile specifies the expected source file for the given todo err scenario
func (*TodoErrScenario) WithType ¶
func (s *TodoErrScenario) WithType(t errors.TODOErrType) *TodoErrScenario
WithType specifies the expected todo err type for the given scenario
type TodocheckScenario ¶
type TodocheckScenario struct {
// contains filtered or unexported fields
}
TodocheckScenario encapsulates the scenario the program is expected to execute. This let's you specify what are the program inputs & what is the expected outputs.
func NewScenario ¶
func NewScenario() *TodocheckScenario
NewScenario to execute against the todocheck program
func (*TodocheckScenario) DeleteTokensCacheAfter ¶
func (s *TodocheckScenario) DeleteTokensCacheAfter() *TodocheckScenario
DeleteTokensCacheAfter the test completes. The tokens cache is derived from the given config file
func (*TodocheckScenario) ExpectExecutionError ¶
func (s *TodocheckScenario) ExpectExecutionError() *TodocheckScenario
ExpectExecutionError on program execution
func (*TodocheckScenario) ExpectOutputText ¶ added in v0.6.0
func (s *TodocheckScenario) ExpectOutputText(output string) *TodocheckScenario
ExpectOutputText sets the expected output
func (*TodocheckScenario) ExpectTodoErr ¶
func (s *TodocheckScenario) ExpectTodoErr(sc *TodoErrScenario) *TodocheckScenario
ExpectTodoErr appends a new todo err scenario to expect from the program execution
func (*TodocheckScenario) OnlyRunOnCI ¶ added in v0.4.0
func (s *TodocheckScenario) OnlyRunOnCI() *TodocheckScenario
OnlyRunOnCI configures this scenario to only execute when executed in a CI environment. If ran locally, this scenario will succeed unconditionally. This is useful in situations when a certain scenario needs specific data available on the CI environment only
func (*TodocheckScenario) RequireAuthToken ¶
func (s *TodocheckScenario) RequireAuthToken(token string) *TodocheckScenario
RequireAuthToken on each issue lookup
func (*TodocheckScenario) Run ¶
func (s *TodocheckScenario) Run() error
Run sets up the environment & executes the configured scenario
func (*TodocheckScenario) SetOfflineTokenWhenRequested ¶
func (s *TodocheckScenario) SetOfflineTokenWhenRequested(token string) *TodocheckScenario
SetOfflineTokenWhenRequested by sending the specified token to the program's standard input
func (*TodocheckScenario) WithAuthTokenFromEnv ¶ added in v0.4.0
func (s *TodocheckScenario) WithAuthTokenFromEnv(envVariable string) *TodocheckScenario
WithAuthTokenFromEnv sets the TODOCHECK_AUTH_TOKEN environment variable by copying the token from the provided environment variable
func (*TodocheckScenario) WithBasepath ¶
func (s *TodocheckScenario) WithBasepath(basepath string) *TodocheckScenario
WithBasepath let's you specify the --basepath flag passed to the program
func (*TodocheckScenario) WithBinary ¶
func (s *TodocheckScenario) WithBinary(binaryLoc string) *TodocheckScenario
WithBinary let's you specify the location of the todocheck binary to test with
func (*TodocheckScenario) WithConfig ¶
func (s *TodocheckScenario) WithConfig(cfgPath string) *TodocheckScenario
WithConfig let's you specify the --config flag passed to the program. By default, it is also used for the test environment config. If you want to specify a different test environment config, see WithTestEnvConfig
func (*TodocheckScenario) WithEnvVariable ¶ added in v0.2.0
func (s *TodocheckScenario) WithEnvVariable(key, value string) *TodocheckScenario
WithEnvVariable sets a custom environment variable for the period of test execution
func (*TodocheckScenario) WithGitConfig ¶ added in v0.3.0
func (s *TodocheckScenario) WithGitConfig(origunURL string) *TodocheckScenario
WithGitConfig let's you specify a custom git configuration to be created under basepath directory.
func (*TodocheckScenario) WithIssue ¶
func (s *TodocheckScenario) WithIssue(issueID string, status issuetracker.Status) *TodocheckScenario
WithIssue sets up a mock issue in your issue tracker with the given status
func (*TodocheckScenario) WithIssueTracker ¶
func (s *TodocheckScenario) WithIssueTracker(issueTracker issuetracker.Type) *TodocheckScenario
WithIssueTracker let's you specify what issue tracker to execute the scenario with
func (*TodocheckScenario) WithJSONOutput ¶ added in v0.4.0
func (s *TodocheckScenario) WithJSONOutput() *TodocheckScenario
WithJSONOutput sets the output to be in JSON format
func (*TodocheckScenario) WithTestEnvConfig ¶
func (s *TodocheckScenario) WithTestEnvConfig(cfgPath string) *TodocheckScenario
WithTestEnvConfig let's you specify a configuration used for the test environment, which can be different from the --config flag passed to todocheck
func (*TodocheckScenario) WithVersionFlag ¶ added in v0.3.0
func (s *TodocheckScenario) WithVersionFlag() *TodocheckScenario
WithVersionFlag sets the --version flag when calling the todocheck binary