Skip to content

Add proto.Message roundtrip tests for JSON/YAML output#64

Closed
apstndb wants to merge 1 commit into
mainfrom
test/proto-roundtrip
Closed

Add proto.Message roundtrip tests for JSON/YAML output#64
apstndb wants to merge 1 commit into
mainfrom
test/proto-roundtrip

Conversation

@apstndb

@apstndb apstndb commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add proto_roundtrip_test.go exercising *sppb.ResultSet and submessages (ResultSetMetadata, ResultSetStats) through the production jq output pipeline.
  • Verify protojson map roundtrip (TestResultSetProtoJSONRoundtrip) and full encode/decode roundtrip for both --format=json and --format=yaml (TestResultSet*ProtoRoundtrip).
  • Reuse synthetic CSV/YAML fixtures and frozen PROFILE JSON fixtures (testdata/profile/*.json).

Test plan

  • go test ./...
  • go test -run 'TestResultSet.*ProtoRoundtrip|TestResultSetProtoJSONRoundtrip' -v .

Made with Cursor

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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread proto_roundtrip_test.go
Comment on lines +3 to +6
import (
"bytes"
"encoding/json"
"testing"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Add the "fmt" package to the imports so it can be used to return formatted errors for unsupported formats in decodeFormatToMap.

Suggested change
import (
"bytes"
"encoding/json"
"testing"
import (
"bytes"
"encoding/json"
"fmt"
"testing"

Comment thread proto_roundtrip_test.go
Comment on lines +94 to +96
default:
return nil, nil
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
default:
return nil, nil
}
default:
return nil, fmt.Errorf("unsupported format: %s", format)
}

@apstndb

apstndb commented Jun 28, 2026

Copy link
Copy Markdown
Owner Author

Closing: roundtrip tests are redundant with existing YAML goldens and the protojson→jq pipeline; not required for the goccy migration.

@apstndb apstndb closed this Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant