From 78bf96de9ef575902d162562b0faa47df2df931a Mon Sep 17 00:00:00 2001 From: Noah Dietz Date: Thu, 13 Apr 2023 15:34:13 -0700 Subject: [PATCH] fix(AIP-151): allow batch delete an Empty response (#1136) Allow `BatchDelete` to use `Empty` response as is allowed in AIP-235. Fixes #1092 --- rules/aip0151/lro_response_type.go | 2 +- rules/aip0151/lro_response_type_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/aip0151/lro_response_type.go b/rules/aip0151/lro_response_type.go index bdcc18cef..d0b280481 100644 --- a/rules/aip0151/lro_response_type.go +++ b/rules/aip0151/lro_response_type.go @@ -40,7 +40,7 @@ var lroResponse = &lint.MethodRule{ } // Unless this is a Delete method, the response type should not be Empty. - if strings.HasPrefix(m.GetName(), "Delete") { + if strings.HasPrefix(m.GetName(), "Delete") || strings.HasPrefix(m.GetName(), "BatchDelete") { return nil } if t := lro.GetResponseType(); t == "Empty" || t == "google.protobuf.Empty" { diff --git a/rules/aip0151/lro_response_type_test.go b/rules/aip0151/lro_response_type_test.go index 8524b8176..9875e0911 100644 --- a/rules/aip0151/lro_response_type_test.go +++ b/rules/aip0151/lro_response_type_test.go @@ -31,6 +31,7 @@ func TestLROResponse(t *testing.T) { {"InvalidEmptyString", "WriteBook", "", testutils.Problems{{Message: "must set the response type"}}}, {"InvalidGPEmpty", "WriteBook", "google.protobuf.Empty", testutils.Problems{{Message: "Empty"}}}, {"ValidGPEmptyDelete", "DeleteBook", "google.protobuf.Empty", testutils.Problems{}}, + {"ValidGPEmptyDelete", "BatchDeleteBooks", "google.protobuf.Empty", testutils.Problems{}}, } for _, test := range tests { t.Run(test.testName, func(t *testing.T) {