diff --git a/functional-tests/src/lib.rs b/functional-tests/src/lib.rs index ccb7b4b86..eb0282c4e 100644 --- a/functional-tests/src/lib.rs +++ b/functional-tests/src/lib.rs @@ -1229,7 +1229,8 @@ bar: |- r#"{ "foo": "bar", "bar": "baz\nbam" -}"# +} +"# ); } diff --git a/stores/json/store.go b/stores/json/store.go index 3212b5b32..7b8bf3da5 100644 --- a/stores/json/store.go +++ b/stores/json/store.go @@ -330,6 +330,7 @@ func (store *Store) EmitEncryptedFile(in sops.Tree) ([]byte, error) { if err != nil { return nil, fmt.Errorf("Error marshaling to json: %s", err) } + out = append(out, '\n') return out, nil } @@ -340,6 +341,7 @@ func (store *Store) EmitPlainFile(in sops.TreeBranches) ([]byte, error) { if err != nil { return nil, fmt.Errorf("Error marshaling to json: %s", err) } + out = append(out, '\n') return out, nil } diff --git a/stores/json/store_test.go b/stores/json/store_test.go index ba575a049..0f447d869 100644 --- a/stores/json/store_test.go +++ b/stores/json/store_test.go @@ -34,7 +34,8 @@ func TestDecodeJSON(t *testing.T) { } } } -}` +} +` expected := sops.TreeBranch{ sops.TreeItem{ Key: "glossary", @@ -312,7 +313,8 @@ func TestEncodeJSONArrayOfObjects(t *testing.T) { }, 2 ] -}` +} +` store := Store{ config: config.JSONStoreConfig{ Indent: -1, @@ -446,7 +448,8 @@ func TestIndentTwoSpaces(t *testing.T) { }, 2 ] -}` +} +` store := Store{ config: config.JSONStoreConfig{ Indent: 2, @@ -488,7 +491,8 @@ func TestIndentDefault(t *testing.T) { }, 2 ] -}` +} +` store := Store{ config: config.JSONStoreConfig{ Indent: -1, @@ -530,7 +534,8 @@ func TestNoIndent(t *testing.T) { }, 2 ] -}` +} +` store := Store{ config: config.JSONStoreConfig{ Indent: 0, @@ -619,7 +624,8 @@ func TestComments(t *testing.T) { }, 2 ] -}` +} +` store := Store{ config: config.JSONStoreConfig{ Indent: 2,