Skip to content

Commit

Permalink
Use fmt.Sprintf format a ginkgo Should (#688)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
qinqon authored Feb 8, 2021
1 parent 2ae804c commit 687cead
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/e2e/handler/nns_update_timestamp_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package handler

import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -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()))
})
}
})
})
Expand Down

0 comments on commit 687cead

Please sign in to comment.