assert.EqualExportedValues - panic: reflect.MakeSlice of non-slice type [recovered]
import (
"github.com/lib/pq"
)
type User struct {
...
Roles pq.StringArray `json:"roles" gorm:"type:text[]"`
}
----
"github.com/lib/pq"
type StringArray []string //https://github.com/lib/pq/blob/3d613208bca2e74f2a20e04126ed30bcb5c4cc27/array.go#L626
panic: reflect.MakeSlice of non-slice type [recovered]
panic: reflect.MakeSlice of non-slice type
goroutine 86 [running]:
testing.tRunner.func1.2({0x1027680, 0x1246ea0})
C:/Program Files/Go/src/testing/testing.go:1545 +0x238
testing.tRunner.func1()
C:/Program Files/Go/src/testing/testing.go:1548 +0x397
panic({0x1027680?, 0x1246ea0?})
C:/Program Files/Go/src/runtime/panic.go:914 +0x21f
reflect.MakeSlice({0x125aa28, 0x1100c60}, 0x10, 0x10)
C:/Program Files/Go/src/reflect/value.go:3135 +0x171
github.com/stretchr/testify/assert.copyExportedFields({0x1100c60, 0xc0002c8e00})
C:/Users/tommy/go/pkg/mod/github.com/stretchr/[email protected]/assert/assertions.go:113 +0x22f
github.com/stretchr/testify/assert.copyExportedFields({0x111b960, 0xc0002c8e00})
C:/Users/tommy/go/pkg/mod/github.com/stretchr/[email protected]/assert/assertions.go:100 +0x5af
github.com/stretchr/testify/assert.ObjectsExportedFieldsAreEqual({0x111b960?, 0xc0002c8e00?}, {0x111b960, 0xc0002c9000})
C:/Users/tommy/go/pkg/mod/github.com/stretchr/[email protected]/assert/assertions.go:144 +0x27
bitbucket.org/anra-mission-manager/mmx-registration-service/app/tests/repository_test_test.TestGetUserById.func3(0x0?)
C:/Users/tommy/Desktop/anra/repo/mmx-registration-service/app/tests/repository_test/user_test.go:108 +0x12c
testing.tRunner(0xc0005841a0, 0xc00033d900)
C:/Program Files/Go/src/testing/testing.go:1595 +0xff
created by testing.(*T).Run in goroutine 14
C:/Program Files/Go/src/testing/testing.go:1648 +0x3ad
FAIL bitbucket.org/anra-mission-manager/mmx-registration-service/app/tests/repository_test 0.873
Hi! can you give more explanation about what does this error about? a go.dev example like this would help maintainers understand the issue https://go.dev/play/p/AsRNcxCRdWx
Hi there, I've been running into this same issue when using arrays. I've put together an example here: https://go.dev/play/p/XeoP7BQJeQV I'm using Go 1.21.3
thank you for the testcase addition @johnfrankmorgan after some digging, I think it's fixed here https://github.com/stretchr/testify/pull/1473 this should be fixed on the next version
also this issue is duplicate of https://github.com/stretchr/testify/issues/1404
That's brilliant, thanks! 😃
do you have any plan to release some of the fixes? @dolmen
Can confirm this is fixed but not yet released. I intend to tag a release very soon.