From 687cead487e1f6cf01df79a63424665e0238c586 Mon Sep 17 00:00:00 2001 From: Enrique Llorente Pastora Date: Mon, 8 Feb 2021 12:24:54 +0100 Subject: [PATCH] Use fmt.Sprintf format a ginkgo `Should` (#688) Ginkgo Should description allow to pass a string and some arguments but the string has to follow Sprintf format. This change fix one test that was not using "%s" expansion token at the string, also use the lazy initialization mechanism to get the current after eventually is finished. Signed-off-by: Quique Llorente --- test/e2e/handler/nns_update_timestamp_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/e2e/handler/nns_update_timestamp_test.go b/test/e2e/handler/nns_update_timestamp_test.go index 1f2e0a5641..3514782a0d 100644 --- a/test/e2e/handler/nns_update_timestamp_test.go +++ b/test/e2e/handler/nns_update_timestamp_test.go @@ -1,6 +1,7 @@ package handler import ( + "fmt" "time" . "github.com/onsi/ginkgo" @@ -34,15 +35,15 @@ var _ = Describe("[nns] NNS LastSuccessfulUpdateTime", func() { timeout := 3 * nmstatenode.NetworkStateRefresh key := types.NamespacedName{Name: node} - obtainedStatus := shared.NodeNetworkStateStatus{} Consistently(func() shared.NodeNetworkStateStatus { - obtainedStatus = nodeNetworkState(key).Status - return obtainedStatus + return nodeNetworkState(key).Status }, timeout, time.Second).Should(MatchAllFields(Fields{ "CurrentState": WithTransform(shared.State.String, Equal(originalNNS.Status.CurrentState.String())), "LastSuccessfulUpdateTime": Equal(originalNNS.Status.LastSuccessfulUpdateTime), "Conditions": Equal(originalNNS.Status.Conditions), - }), "currentState diff: ", diff.LineDiff(originalNNS.Status.CurrentState.String(), obtainedStatus.CurrentState.String())) + }), func() string { + return fmt.Sprintf("currentState diff: \n%s", diff.LineDiff(originalNNS.Status.CurrentState.String(), nodeNetworkState(key).Status.CurrentState.String())) + }) } }) })