Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent flattening behaviour for empty slices in structs #331

Open
wants to merge 5 commits into
base: v4
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Struct slice yields wrong no of arguments.
  • Loading branch information
dokterbob committed Oct 8, 2022
commit 53187a116ba7fb1d9ec8c4d0b41d74f6048dbf72
33 changes: 33 additions & 0 deletions resp/resp3/flatten_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package resp3

import (
"testing"

"github.com/mediocregopher/radix/v4/resp"
"github.com/stretchr/testify/suite"
)

type FlattenTestSuite struct {
suite.Suite
}

type NestedStruct struct{}

type sliceTestStruct struct {
Other string
Nested []NestedStruct
}

func (s *FlattenTestSuite) TestEmptyNestedSlice() {
testInst := sliceTestStruct{
Other: "hello",
}

flat, err := Flatten(testInst, resp.NewOpts())
s.NoError(err)
s.Equal([]string{"Other", "hello"}, flat)
}

func TestFlattenTestSuite(t *testing.T) {
suite.Run(t, new(FlattenTestSuite))
}