For instance, given the following step definition:
func (s *Steps) ThenTheReturnedErrorsShouldBe(errorsTbl *godog.Table) error {
actualResponse := []*struct {
Code int
Description string
}{
{Code: 123, Description: "Only one error"}, // <-- Only one element here
}
if err := assitdog.NewDefault().CompareToSlice(actualResponse, errorsTbl); err != nil {
return fmt.Errorf("return errors are different from expected: %v", err)
}
return nil
}
And the following step in a scenario:
Then the returned errors should be
| Code | Description |
| 123 | First error |
| 456 | Second error |
I would expect to see an error stating that the number of elements is different. However, I got a panic like the following:
panic: reflect: slice index out of range
goroutine 100 [running]:
testing.tRunner.func1.1(0x15b0220, 0x1727ba0)
/usr/local/Cellar/go/1.15.5/libexec/src/testing/testing.go:1072 +0x30d
testing.tRunner.func1(0xc000316a80)
/usr/local/Cellar/go/1.15.5/libexec/src/testing/testing.go:1075 +0x41a
panic(0x15b0220, 0x1727ba0)
/usr/local/Cellar/go/1.15.5/libexec/src/runtime/panic.go:969 +0x1b9
reflect.Value.Index(0x15a4da0, 0xc000153e00, 0x97, 0x1, 0x1a8bfe0, 0x0, 0x0)
/usr/local/Cellar/go/1.15.5/libexec/src/reflect/value.go:962 +0x1f2
github.com/rdumont/assistdog.(*Assist).CompareToSlice(0xc0003054a0, 0x15a4da0, 0xc000153e00, 0xc00031c7a0, 0x0, 0x0)
/Users/rodrigodumont/go/pkg/mod/github.com/rdumont/assistdog@v0.0.0-20201106100018-168b06230d14/assist.go:212 +0x197
For instance, given the following step definition:
And the following step in a scenario:
I would expect to see an error stating that the number of elements is different. However, I got a panic like the following: