get.porter.sh/porter@v1.3.0/pkg/storage/bundle_test.go (about) 1 package storage 2 3 import ( 4 "encoding/json" 5 "testing" 6 7 "get.porter.sh/porter/pkg/test" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestBundleDocument_MarshalJSON(t *testing.T) { 12 // Validate that we can marshal and unmarshal a bundle to an escaped json string 13 b1 := BundleDocument(exampleBundle) 14 15 data, err := json.Marshal(b1) 16 require.NoError(t, err, "MarshalJSON failed") 17 18 test.CompareGoldenFile(t, "testdata/marshalled_bundle.txt", string(data)) 19 20 var b2 BundleDocument 21 err = json.Unmarshal(data, &b2) 22 require.NoError(t, err, "UnmarshalJSON failed") 23 require.Equal(t, b1, b2, "The bundle didn't survive the round trip") 24 }