Fix minikube tunnel repeated printout of status

The check to suppress repeated status printout does not work, it compares
pointers, while the state is always cloned when it is passed to the Report
function. Do the DeepEqual check instead and change the test to be real.
pull/14933/head
Oldřich Jedlička 2022-09-09 18:28:44 +02:00
parent 1d80003313
commit a5fba12f97
2 changed files with 7 additions and 6 deletions

View File

@ -18,6 +18,7 @@ package tunnel
import (
"fmt"
"reflect"
"io"
"strings"
@ -38,7 +39,7 @@ type simpleReporter struct {
const noErrors = "no errors"
func (r *simpleReporter) Report(tunnelState *Status) {
if r.lastState == tunnelState {
if reflect.DeepEqual(r.lastState, tunnelState) {
return
}
r.lastState = tunnelState

View File

@ -103,11 +103,11 @@ Got: "%s"`, tc.name, tc.expectedOutput, out.output)
// testing deduplication
out := &recordingWriter{}
reporter := newReporter(out)
reporter.Report(testCases[0].tunnelState)
reporter.Report(testCases[0].tunnelState)
reporter.Report(testCases[1].tunnelState)
reporter.Report(testCases[1].tunnelState)
reporter.Report(testCases[0].tunnelState)
reporter.Report(testCases[0].tunnelState.Clone())
reporter.Report(testCases[0].tunnelState.Clone())
reporter.Report(testCases[1].tunnelState.Clone())
reporter.Report(testCases[1].tunnelState.Clone())
reporter.Report(testCases[0].tunnelState.Clone())
expectedOutput := fmt.Sprintf("%s%s%s",
testCases[0].expectedOutput,