(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func 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 | |
| 51 | func TestGetObjectHashIgnoreEmptyKeys(t *testing.T) { |
| 52 | type simple struct { |
nothing calls this directly
no test coverage detected