Skip to content

Commit

Permalink
Add a test for dotenv output ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
edofic committed Aug 4, 2022
1 parent 33e3bd1 commit d544170
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions stores/dotenv/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,20 @@ func TestEmitValueNonstring(t *testing.T) {
_, err := (&Store{}).EmitValue(BRANCH)
assert.NotNil(t, err)
}

func TestEmitEncryptedFileStability(t *testing.T) {
// emit the same tree multiple times to ensure the output is stable
// i.e. emitting the same tree always yields exactly the same output
var previous []byte
for i := 0; i < 10; i += 1 {
bytes, err := (&Store{}).EmitEncryptedFile(sops.Tree{
Branches: []sops.TreeBranch{{}},
})
assert.Nil(t, err)
assert.NotEmpty(t, bytes)
if previous != nil {
assert.Equal(t, previous, bytes)
}
previous = bytes
}
}

0 comments on commit d544170

Please sign in to comment.