This is an automated email from the ASF dual-hosted git repository.
pbacsko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git
The following commit(s) were added to refs/heads/master by this push:
new 070a678b [YUNIKORN-2670] Improve util funtion's test coverage (#888)
070a678b is described below
commit 070a678b52b85952ad1d4870bfd8dfbd5c5a074f
Author: SP12893678 <[email protected]>
AuthorDate: Tue Jun 11 19:22:47 2024 +0200
[YUNIKORN-2670] Improve util funtion's test coverage (#888)
Closes: #888
Signed-off-by: Peter Bacsko <[email protected]>
---
pkg/common/utils_test.go | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/pkg/common/utils_test.go b/pkg/common/utils_test.go
index fb62e46e..25b044a9 100644
--- a/pkg/common/utils_test.go
+++ b/pkg/common/utils_test.go
@@ -27,6 +27,8 @@ import (
"gotest.tools/v3/assert"
+ "github.com/google/uuid"
+
"github.com/apache/yunikorn-scheduler-interface/lib/go/common"
"github.com/apache/yunikorn-scheduler-interface/lib/go/si"
)
@@ -380,3 +382,35 @@ func TestGetConfigurationInt(t *testing.T) {
})
}
}
+
+func TestZeroTimeInUnixNano(t *testing.T) {
+ // zero time
+ var nilValue *int64 = nil
+ assert.Equal(t, ZeroTimeInUnixNano(time.Time{}), nilValue)
+
+ // non-zero time
+ date := time.Date(2024, time.June, 6, 0, 0, 0, 0, time.UTC)
+ assert.Equal(t, *ZeroTimeInUnixNano(date), date.UnixNano())
+
+ // time in different timezone
+ date = time.Date(2024, time.June, 6, 0, 0, 0, 0,
time.FixedZone("UTC+8", 8*60*60))
+ assert.Equal(t, *ZeroTimeInUnixNano(date), date.UnixNano())
+}
+
+func TestGetNewUUID(t *testing.T) {
+ newUUID := GetNewUUID()
+ if _, err := uuid.Parse(newUUID); err != nil {
+ t.Errorf("Generated UUID is not valid: %s", newUUID)
+ }
+}
+
+func TestIsRecoveryQueue(t *testing.T) {
+ // valid case
+ assert.Assert(t, IsRecoveryQueue("root.@recovery@"))
+ assert.Assert(t, IsRecoveryQueue("ROOT.@RECOVERY@"))
+ assert.Assert(t, IsRecoveryQueue("RoOT.@rECoVeRY@"))
+
+ // invalid case
+ assert.Assert(t, !IsRecoveryQueue("otherQueue"))
+ assert.Assert(t, !IsRecoveryQueue(""))
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]