containerized-data-importer/vendor/github.com/appscode/jsonpatch/jsonpatch_json_test.go
Alexander Wels 45eecea14e
Added conditions to match the HCO requirements. (#910)
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-08-28 18:36:44 -04:00

34 lines
697 B
Go

package jsonpatch_test
import (
"testing"
"github.com/appscode/jsonpatch"
"github.com/stretchr/testify/assert"
)
func TestMarshalNullableValue(t *testing.T) {
p1 := jsonpatch.Operation{
Operation: "replace",
Path: "/a1",
Value: nil,
}
assert.JSONEq(t, `{"op":"replace", "path":"/a1","value":null}`, p1.Json())
p2 := jsonpatch.Operation{
Operation: "replace",
Path: "/a2",
Value: "v2",
}
assert.JSONEq(t, `{"op":"replace", "path":"/a2", "value":"v2"}`, p2.Json())
}
func TestMarshalNonNullableValue(t *testing.T) {
p1 := jsonpatch.Operation{
Operation: "remove",
Path: "/a1",
}
assert.JSONEq(t, `{"op":"remove", "path":"/a1"}`, p1.Json())
}