Skip to content

Commit

Permalink
chore(store): Parameters marshalling rountrip test (#74)
Browse files Browse the repository at this point in the history
If this test had existed, the bug fixed by #69 wouldn't happen
  • Loading branch information
Wondertan committed Jul 10, 2023
1 parent 3975d5d commit badf27b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions store/options_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package store

import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestOptionsWithParams(t *testing.T) {
Expand All @@ -17,3 +19,16 @@ func TestOptionsWithParams(t *testing.T) {
opt(&params)
assert.Equal(t, size, params.StoreCacheSize)
}

func TestDefaultParamsMarshalRountrip(t *testing.T) {
paramsIn := DefaultParameters()
paramsOut := Parameters{}

bytes, err := json.Marshal(paramsIn)
require.NoError(t, err)

err = json.Unmarshal(bytes, &paramsOut)
require.NoError(t, err)

assert.Equal(t, paramsIn, paramsOut)
}

0 comments on commit badf27b

Please sign in to comment.