...

Source file src/gomodules.xyz/jsonpatch/v2/jsonpatch_json_test.go

Documentation: gomodules.xyz/jsonpatch/v2

     1  package jsonpatch_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  	"gomodules.xyz/jsonpatch/v2"
     8  )
     9  
    10  func TestMarshalNullableValue(t *testing.T) {
    11  	p1 := jsonpatch.Operation{
    12  		Operation: "replace",
    13  		Path:      "/a1",
    14  		Value:     nil,
    15  	}
    16  	assert.JSONEq(t, `{"op":"replace", "path":"/a1","value":null}`, p1.Json())
    17  
    18  	p2 := jsonpatch.Operation{
    19  		Operation: "replace",
    20  		Path:      "/a2",
    21  		Value:     "v2",
    22  	}
    23  	assert.JSONEq(t, `{"op":"replace", "path":"/a2", "value":"v2"}`, p2.Json())
    24  }
    25  
    26  func TestMarshalNonNullableValue(t *testing.T) {
    27  	p1 := jsonpatch.Operation{
    28  		Operation: "remove",
    29  		Path:      "/a1",
    30  	}
    31  	assert.JSONEq(t, `{"op":"remove", "path":"/a1"}`, p1.Json())
    32  
    33  }
    34  

View as plain text