Skip to content

Commit

Permalink
Add Action.Caption()
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Nov 28, 2020
1 parent ac7f6e4 commit 32f7b56
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions action.advancetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ type advanceTimeAction struct {
loc location.Location
}

func (a advanceTimeAction) Caption() string {
return fmt.Sprintf(
"advancing time %s",
a.adj.Description(),
)
}

func (a advanceTimeAction) Banner() string {
return fmt.Sprintf(
"ADVANCING TIME (%s)",
Expand Down
4 changes: 4 additions & 0 deletions action.call.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ type callAction struct {
loc location.Location
}

func (a callAction) Caption() string {
return "calling user-defined function"
}

func (a callAction) Banner() string {
return "CALLING USER-DEFINED FUNCTION"
}
Expand Down
7 changes: 7 additions & 0 deletions action.dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ type dispatchAction struct {
loc location.Location
}

func (a dispatchAction) Caption() string {
return inflect.Sprintf(
a.r,
"<producing> %t <message>",
a.m,
)
}
func (a dispatchAction) Banner() string {
return inflect.Sprintf(
a.r,
Expand Down
9 changes: 9 additions & 0 deletions action.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ import (
// Actions always attempt to cause some state change within the engine or
// application.
type Action interface {
// Caption returns the caption that should be used for this action in the
// test report.
//
// It must be formatted according to the documentation on the
// report.Step.Caption field.
Caption() string

// Banner returns a human-readable banner to display in the logs when this
// action is performed.
//
// The banner text should be in uppercase, and worded in the present tense,
// for example "DOING ACTION".
//
// DEPRECATED: TODO: remove
Banner() string

// Location returns the location within the code that the action was
Expand Down
1 change: 1 addition & 0 deletions action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type noopAction struct {
err error
}

func (a noopAction) Caption() string { return "[no-op]" }
func (a noopAction) Banner() string { return "[NO-OP]" }
func (a noopAction) Location() location.Location { return location.Location{Func: "<noop>"} }
func (a noopAction) ConfigurePredicate(*PredicateOptions) {}
Expand Down

0 comments on commit 32f7b56

Please sign in to comment.