Skip to content

Commit a5fba12

Browse files
committed
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.
1 parent 1d80003 commit a5fba12

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

pkg/minikube/tunnel/reporter.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package tunnel
1818

1919
import (
2020
"fmt"
21+
"reflect"
2122

2223
"io"
2324
"strings"
@@ -38,7 +39,7 @@ type simpleReporter struct {
3839
const noErrors = "no errors"
3940

4041
func (r *simpleReporter) Report(tunnelState *Status) {
41-
if r.lastState == tunnelState {
42+
if reflect.DeepEqual(r.lastState, tunnelState) {
4243
return
4344
}
4445
r.lastState = tunnelState

pkg/minikube/tunnel/reporter_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ Got: "%s"`, tc.name, tc.expectedOutput, out.output)
103103
// testing deduplication
104104
out := &recordingWriter{}
105105
reporter := newReporter(out)
106-
reporter.Report(testCases[0].tunnelState)
107-
reporter.Report(testCases[0].tunnelState)
108-
reporter.Report(testCases[1].tunnelState)
109-
reporter.Report(testCases[1].tunnelState)
110-
reporter.Report(testCases[0].tunnelState)
106+
reporter.Report(testCases[0].tunnelState.Clone())
107+
reporter.Report(testCases[0].tunnelState.Clone())
108+
reporter.Report(testCases[1].tunnelState.Clone())
109+
reporter.Report(testCases[1].tunnelState.Clone())
110+
reporter.Report(testCases[0].tunnelState.Clone())
111111

112112
expectedOutput := fmt.Sprintf("%s%s%s",
113113
testCases[0].expectedOutput,

0 commit comments

Comments
 (0)