From be241768bb19761c630427a0ebfef7fd453835fa Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Sat, 13 Jul 2024 13:35:57 +0300 Subject: [PATCH] Added reset method to our ConsoleRecorder interface. --- consoleout/consoleout.go | 9 +++++++-- consoleout/drv_logger.go | 9 ++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/consoleout/consoleout.go b/consoleout/consoleout.go index c83138e..e71ffec 100644 --- a/consoleout/consoleout.go +++ b/consoleout/consoleout.go @@ -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 diff --git a/consoleout/drv_logger.go b/consoleout/drv_logger.go index c9b1f3a..aeea693 100644 --- a/consoleout/drv_logger.go +++ b/consoleout/drv_logger.go @@ -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 {