mirror of
https://github.com/kubevirt/containerized-data-importer.git
synced 2025-06-03 06:30:22 +00:00
34 lines
697 B
Go
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())
|
|
|
|
}
|