test: verify array of struct decoding using DecodeOptionProto#835
test: verify array of struct decoding using DecodeOptionProto#835olavloite wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a new integration test, TestArrayOfStruct, to verify querying and decoding an array of structs. The review feedback suggests using cmp.Diff instead of reflect.DeepEqual to compare the results, which provides a clearer, field-by-field diff in case of test failures.
| if !reflect.DeepEqual(allEntries, expected) { | ||
| t.Errorf("allEntries mismatch\n Got: %+v\nWant: %+v", allEntries, expected) | ||
| } |
There was a problem hiding this comment.
Using reflect.DeepEqual on slices of pointers (like []*Entry) will print pointer addresses (e.g., 0xc000...) instead of the actual struct values in the test failure output, making debugging difficult. Since github.com/google/go-cmp/cmp is already imported and used in this file, using cmp.Diff is more idiomatic and provides a readable, field-by-field diff of the mismatch.
| if !reflect.DeepEqual(allEntries, expected) { | |
| t.Errorf("allEntries mismatch\n Got: %+v\nWant: %+v", allEntries, expected) | |
| } | |
| if diff := cmp.Diff(expected, allEntries); diff != "" { | |
| t.Errorf("allEntries mismatch (-want +got):\n%s", diff) | |
| } |
|
LGTM. The test verifies that complex arrays of structs can be parsed and decoded into custom Go structs using |
Adds TestArrayOfStruct to verify that arrays of structs can be decoded using the spannerdriver.ExecOptions{DecodeOption: spannerdriver.DecodeOptionProto} option and scanning into a spanner.GenericColumnValue.
Fixes #309