Skip to content

Commit

Permalink
feat: add proto marshaler support
Browse files Browse the repository at this point in the history
Signed-off-by: Thejas Nanjunda <[email protected]>
  • Loading branch information
thejasn committed Oct 10, 2021
1 parent 8be7d28 commit 2abca12
Show file tree
Hide file tree
Showing 9 changed files with 1,468 additions and 12 deletions.
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/stretchr/testify v1.7.0
github.com/vmihailenco/msgpack v4.0.4+incompatible
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
google.golang.org/protobuf v1.26.0
)

require (
Expand All @@ -41,12 +42,11 @@ require (
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/sirupsen/logrus v1.6.0 // indirect
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 // indirect
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 // indirect
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect
golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 // indirect
google.golang.org/appengine v1.4.0 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
k8s.io/apimachinery v0.0.0-20191123233150-4c4803ed55e3 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apimachinery v0.23.0-alpha.2 // indirect
)
101 changes: 94 additions & 7 deletions go.sum

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions marshaler/marshaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,41 @@ func TestClearWhenError(t *testing.T) {
// Then
assert.Equal(t, expectedErr, err)
}

func TestNestedStructFailure(t *testing.T) {
type parent struct {
msg string
}

type child struct {
p parent
}

// Given
ctrl := gomock.NewController(t)

ctx := context.Background()

cacheValue := &child{
p: parent{
msg: "hi",
},
}

cacheValueBytes, err := msgpack.Marshal(cacheValue)
if err != nil {
assert.Error(t, err)
}

cache := mocksCache.NewMockCacheInterface(ctrl)
cache.EXPECT().Get(ctx, "my-key").Return(cacheValueBytes, nil)

marshaler := New(cache)

// When
value, err := marshaler.Get(ctx, "my-key", new(child))

// Then
assert.Nil(t, err)
assert.NotEqual(t, cacheValue, value)
}
Loading

0 comments on commit 2abca12

Please sign in to comment.