Add proto.Message roundtrip tests for JSON/YAML output#64
Conversation
Verify ResultSet and submessages survive jq encode/decode through protojson after YAML or JSON formatting using PROFILE fixtures. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a new test file proto_roundtrip_test.go to verify the roundtrip serialization and deserialization of Spanner ResultSet proto messages to and from JSON and YAML formats. The review feedback suggests improving error handling in decodeFormatToMap by returning an explicit error for unsupported formats instead of silently returning nil, nil, which also requires importing the fmt package.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| import ( | ||
| "bytes" | ||
| "encoding/json" | ||
| "testing" |
| default: | ||
| return nil, nil | ||
| } |
There was a problem hiding this comment.
Instead of silently returning nil, nil when an unsupported format is provided, return an explicit error. This prevents potential nil pointer dereferences or confusing failures downstream in assertProtoFormatRoundtrip.
| default: | |
| return nil, nil | |
| } | |
| default: | |
| return nil, fmt.Errorf("unsupported format: %s", format) | |
| } |
|
Closing: roundtrip tests are redundant with existing YAML goldens and the protojson→jq pipeline; not required for the goccy migration. |
Summary
proto_roundtrip_test.goexercising*sppb.ResultSetand submessages (ResultSetMetadata,ResultSetStats) through the production jq output pipeline.TestResultSetProtoJSONRoundtrip) and full encode/decode roundtrip for both--format=jsonand--format=yaml(TestResultSet*ProtoRoundtrip).testdata/profile/*.json).Test plan
go test ./...go test -run 'TestResultSet.*ProtoRoundtrip|TestResultSetProtoJSONRoundtrip' -v .Made with Cursor