chia7712 commented on code in PR #879:
URL: https://github.com/apache/yunikorn-k8shim/pull/879#discussion_r1683707893
##########
pkg/common/utils/utils_test.go:
##########
@@ -1140,3 +1211,30 @@ func TestConvert2PriorityClass(t *testing.T) {
assert.Assert(t, result != nil)
assert.Equal(t, result.PreemptionPolicy, &preemptLower)
}
+
+func TestWaitForCondition(t *testing.T) {
+ target := false
+ eval := func() bool {
+ return target
+ }
+ tests := []struct {
+ input bool
+ interval time.Duration
+ timeout time.Duration
+ output error
+ }{
+ {true, time.Duration(1) * time.Second, time.Duration(2) *
time.Second, nil},
+ {false, time.Duration(1) * time.Second, time.Duration(2) *
time.Second, ErrorTimeout},
+ {true, time.Duration(3) * time.Second, time.Duration(2) *
time.Second, nil},
+ {false, time.Duration(3) * time.Second, time.Duration(2) *
time.Second, ErrorTimeout},
+ }
+ for _, test := range tests {
+ target = test.input
+ get := WaitForCondition(eval, test.timeout, test.interval)
+ if test.output == nil {
+ assert.NilError(t, get)
+ } else {
+ assert.Equal(t, get.Error(), test.output.Error())
+ }
+ }
+}
Review Comment:
I guess that test case is another sort of "consistent result"
https://github.com/apache/yunikorn-core/blob/21303191a9c9ee791de3371ddca973df51b7a755/pkg/common/utils_test.go#L239
Hence, I'm fine to keep this test case :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]