Repository navigation
test(contract): pass --uris as a JSON array - #55
Merged
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the contract tests in required_flags_test.go to verify that the --uris flag correctly sends a JSON array in the request body. The feedback suggests checking the error returned by io.ReadAll to prevent silent failures, and using a type assertion instead of fmt.Sprint on the atomic value to safely handle potential nil values and improve idiomatic Go usage.
wanlin31
approved these changes
Sep 30, 2026
copybara/990640099 regenerates the CLI with cli.arrayFlagFormat: json,
so files register --uris takes one JSON array and rejects the bare
repeatable value this test passed ("expected a JSON array").
Pass '["gs://bucket/object"]' and assert the request body carries the
URI as an array element ({"uris":["gs://bucket/object"]}), so the test
also catches the array text being sent as a single string.
Address review: read the captured body with a type assertion instead of fmt.Sprint on the atomic.Value (no request reads as "", not <nil>), and quote both sides of the mismatch so whitespace is visible.
2ynn
force-pushed
the
tests/990640099
branch
from
September 30, 2026 15:34
32f3b7d to
93fb7a0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
copybara/990640099 regenerates the CLI with
cli.arrayFlagFormat: json, sofiles register --uristakes one JSON array and rejects the bare repeatable value this test passed ("expected a JSON array").Pass '["gs://bucket/object"]' and assert the request body carries the URI as an array element ({"uris":["gs://bucket/object"]}), so the test also catches the array text being sent as a single string.