github.com/docker/compose-on-kubernetes@v0.5.0/internal/patch/patch_test.go (about)

     1  package patch
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestToJSON(t *testing.T) {
    10  	buf, err := New().
    11  		Replace("/path1", "value").
    12  		Remove("/path2").
    13  		AddKV("/path3", "key", "value").
    14  		ToJSON()
    15  
    16  	assert.NoError(t, err)
    17  	assert.EqualValues(t, `[`+
    18  		`{"op":"replace","path":"/path1","value":"value"},`+
    19  		`{"op":"remove","path":"/path2"},`+
    20  		`{"op":"add","path":"/path3","value":{"key":"value"}}`+
    21  		`]`, buf)
    22  }
    23  
    24  func TestToJSONEmpty(t *testing.T) {
    25  	buf, err := New().ToJSON()
    26  
    27  	assert.NoError(t, err)
    28  	assert.EqualValues(t, "[]", buf)
    29  }