From a5fba12f971780effc2d95ea3a016e39ab929185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Old=C5=99ich=20Jedli=C4=8Dka?= Date: Fri, 9 Sep 2022 18:28:44 +0200 Subject: [PATCH] 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. --- pkg/minikube/tunnel/reporter.go | 3 ++- pkg/minikube/tunnel/reporter_test.go | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/minikube/tunnel/reporter.go b/pkg/minikube/tunnel/reporter.go index a1ee16b8be..8535a7dcdf 100644 --- a/pkg/minikube/tunnel/reporter.go +++ b/pkg/minikube/tunnel/reporter.go @@ -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 diff --git a/pkg/minikube/tunnel/reporter_test.go b/pkg/minikube/tunnel/reporter_test.go index 8cdb27d57f..d5dbbd0a19 100644 --- a/pkg/minikube/tunnel/reporter_test.go +++ b/pkg/minikube/tunnel/reporter_test.go @@ -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,