Test to ensure that InjectJSONProperties does not mutate the given byte slice, and instead only returns a modified copy.
(t *testing.T)
| 807 | |
| 808 | // Test to ensure that InjectJSONProperties does not mutate the given byte slice, and instead only returns a modified copy. |
| 809 | func TestInjectJSONPropertiesMutable(t *testing.T) { |
| 810 | origBytes := []byte(`{"orig":true}`) |
| 811 | |
| 812 | newBytes, err := InjectJSONProperties(origBytes, KVPair{Key: "updated", Val: true}) |
| 813 | require.NoError(t, err) |
| 814 | assert.NotEqual(t, origBytes, newBytes) |
| 815 | |
| 816 | assert.Contains(t, string(newBytes), `"updated":true`) |
| 817 | assert.NotContains(t, string(origBytes), `"updated":true`) |
| 818 | |
| 819 | } |
| 820 | |
| 821 | func TestInjectJSONProperties(t *testing.T) { |
| 822 | newKV := KVPair{ |
nothing calls this directly
no test coverage detected