-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add binding testing and multiple bindings test data to compliance service #1150
feat: add binding testing and multiple bindings test data to compliance service #1150
Conversation
…multiple bindings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a first pass, but let me do a second pass next week. I think it's looking good, but I want to think some things through.
cmd/gapic-showcase/endpoint_test.go
Outdated
@@ -174,7 +175,7 @@ func TestRESTCalls(t *testing.T) { | |||
log.Fatal(err) | |||
} | |||
if got, want := string(body), testCase.want; noSpace(got) != noSpace(want) { | |||
t.Errorf("testcase %2d: body: got `%s`, want %s", idx, got, want) | |||
t.Errorf("testcase %2d: body: got `%s`, want `%s`", idx, noSpace(got), noSpace(want)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use %q
instead of backticking the %s
.
Also, for the error message, isn';t it clearer to leave the whitespace in for readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I think being able to see the real assert condition is more convenient. In my case e.g. there was an issue with a tab, invisible in the 'readable' version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so the problem might be that noSpace
does not remove \t
. Maybe it should, and then you can have the asserts use noSpace
but the t.Errorf
remain readable.
@@ -116,10 +119,13 @@ message RepeatRequest { | |||
optional int32 p_int32 = 7; | |||
optional int64 p_int64 = 8; | |||
optional double p_double = 9; | |||
|
|||
optional string intended_binding_uri = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would place this near the server_verify
field, since it's not testing the data fromat preservation like the rest of the compliance suite is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
util/genrest/resttools/constants.go
Outdated
@@ -56,3 +56,6 @@ func init() { | |||
|
|||
RegexLiteral = fmt.Sprintf(`^[%s]+`, CharsLiteral) | |||
} | |||
|
|||
// A key-type for storing binding URI value in the Context | |||
type BindingURIKey string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the uses of this are BindingUriKey("bindingUri")
, AFAICT. Why not define const BindingUriKey string="bindingUri"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the constant has it's own string-derived type instead of string because (as I understand) the Context is a shared space so if someone else wants to have a "bindingUri" it'll be in a separate type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see what you mean about the type. The doc stipulates using non-built-in types to avoid collisions with other packages, since the type, not just the name, presumably plays a part in the lookup.
@@ -217,6 +217,16 @@ func prepRepeatDataPathResourceTest(request *genproto.RepeatRequest) (verb strin | |||
name = "Compliance.RepeatDataPathResource" | |||
info := request.GetInfo() | |||
|
|||
if strings.HasPrefix(info.GetFString(), "first/") { | |||
return prepRepeatDataPathResourceTestFirstBinding(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(no action needed) I think this is fine, but it makes me think in the future we should change the first/
and second/
in the URL templates to other names for clarity, like blue
and cyan
or something.....
// Separately checking that the binding in the client request matches binding in the test suite. | ||
// This guards against the test suite file being wrong on the client. | ||
if expectedRequest.GetIntendedBindingUri() != received.GetIntendedBindingUri() { | ||
return fmt.Errorf("(ComplianceSuiteRequestBindingMismatchError) intended binding of request %q do not match test suite (expected: %s, received: %s)", name, expectedRequest.GetIntendedBindingUri(), received.GetIntendedBindingUri()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/do not/does not/
util/genrest/resttools/constants.go
Outdated
@@ -56,3 +56,6 @@ func init() { | |||
|
|||
RegexLiteral = fmt.Sprintf(`^[%s]+`, CharsLiteral) | |||
} | |||
|
|||
// A key-type for storing binding URI value in the Context | |||
type BindingURIKey string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see what you mean about the type. The doc stipulates using non-built-in types to avoid collisions with other packages, since the type, not just the name, presumably plays a part in the lookup.
cmd/gapic-showcase/endpoint_test.go
Outdated
@@ -174,7 +175,7 @@ func TestRESTCalls(t *testing.T) { | |||
log.Fatal(err) | |||
} | |||
if got, want := string(body), testCase.want; noSpace(got) != noSpace(want) { | |||
t.Errorf("testcase %2d: body: got `%s`, want %s", idx, got, want) | |||
t.Errorf("testcase %2d: body: got `%s`, want `%s`", idx, noSpace(got), noSpace(want)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so the problem might be that noSpace
does not remove \t
. Maybe it should, and then you can have the asserts use noSpace
but the t.Errorf
remain readable.
Split into semantically meaningful commits for reading convenience.