MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestInjectJSONPropertiesMutable

Function TestInjectJSONPropertiesMutable

base/util_test.go:809–819  ·  view source on GitHub ↗

Test to ensure that InjectJSONProperties does not mutate the given byte slice, and instead only returns a modified copy.

(t *testing.T)

Source from the content-addressed store, hash-verified

807
808// Test to ensure that InjectJSONProperties does not mutate the given byte slice, and instead only returns a modified copy.
809func 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
821func TestInjectJSONProperties(t *testing.T) {
822 newKV := KVPair{

Callers

nothing calls this directly

Calls 2

InjectJSONPropertiesFunction · 0.85
ContainsMethod · 0.65

Tested by

no test coverage detected