Skip to content

Commit

Permalink
Added reset method to our ConsoleRecorder interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
skx committed Jul 13, 2024
1 parent bae8c6c commit be24176
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions consoleout/consoleout.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ type ConsoleDriver interface {
}

// ConsoleRecorder is an interface that allows returning the contents that
// have been previously sent to the console
// have been previously sent to the console.
//
// This is used solely for integration tests.
type ConsoleRecorder interface {

//GetOutput returns the contents which have been displayed.
// GetOutput returns the contents which have been displayed.
GetOutput() string

// Reset removes any stored state.
Reset()
}

// This is a map of known-drivers
Expand Down
9 changes: 8 additions & 1 deletion consoleout/drv_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ func (ol *OutputLoggingDriver) SetWriter(w io.Writer) {

// GetOutput returns our history.
//
// This is part of the ConsoleRecorder interface
// This is part of the ConsoleRecorder interface.
func (ol *OutputLoggingDriver) GetOutput() string {
return ol.history
}

// Reset truncates our saved history.
//
// This is part of the ConsoleRecorder interface.
func (ol *OutputLoggingDriver) Reset() {
ol.history = ""
}

// init registers our driver, by name.
func init() {
Register("logger", func() ConsoleDriver {
Expand Down

0 comments on commit be24176

Please sign in to comment.