MCPcopy Index your code
hub / github.com/NVIDIA/gpu-operator / TestGetObjectHash

Function TestGetObjectHash

internal/utils/utils_test.go:26–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestGetObjectHash(t *testing.T) {
27 type simple struct {
28 Name string
29 Count int
30 }
31
32 t.Run("deterministic", func(t *testing.T) {
33 obj := simple{Name: "a", Count: 1}
34 assert.Equal(t, GetObjectHash(obj), GetObjectHash(obj))
35 })
36
37 t.Run("different values produce different hashes", func(t *testing.T) {
38 obj1 := simple{Name: "a", Count: 1}
39 obj2 := simple{Name: "b", Count: 1}
40 assert.NotEqual(t, GetObjectHash(obj1), GetObjectHash(obj2))
41 })
42
43 t.Run("zero-valued field affects hash", func(t *testing.T) {
44 withZero := simple{Name: "a", Count: 0}
45 withNonZero := simple{Name: "a", Count: 1}
46 assert.NotEqual(t, GetObjectHash(withZero), GetObjectHash(withNonZero))
47 })
48
49}
50
51func TestGetObjectHashIgnoreEmptyKeys(t *testing.T) {
52 type simple struct {

Callers

nothing calls this directly

Calls 2

GetObjectHashFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected