Skip to content

Commit

Permalink
chore: add test for new case
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdietz committed Oct 22, 2024
1 parent d0ea8d4 commit 12ffa77
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions rules/aip0133/method_signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,42 @@ func TestMethodSignature(t *testing.T) {
t.Errorf(diff)
}
})
// Add a separate test for the LRO case rather than introducing yet
// another knob on the above test.
t.Run("NonStandardResourceFieldName", func(t *testing.T) {
file := testutils.ParseProto3String(t, `
import "google/api/client.proto";
import "google/api/resource.proto";
import "google/longrunning/operations.proto";
service Library {
rpc CreateBook(CreateBookRequest) returns (google.longrunning.Operation) {
option (google.api.method_signature) = "book,book_id";
option (google.longrunning.operation_info) = {
response_type: "Book"
metadata_type: "Book"
};
}
}
message CreateBookRequest {
Book not_book = 1;
string book_id = 2;
}
message Book {
option (google.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "books/{book}"
};
}
`)
want := testutils.Problems{
{
Message: "not_book,book",
Suggestion: `option (google.api.method_signature) = "not_book,book_id";`,
Descriptor: file.GetServices()[0].GetMethods()[0],
},
}
if diff := want.Diff(methodSignature.Lint(file)); diff != "" {
t.Errorf(diff)
}
})
}

0 comments on commit 12ffa77

Please sign in to comment.