Skip to content

Commit

Permalink
tests: Added resource name proto test for loose resource pattern vali…
Browse files Browse the repository at this point in the history
…dation
  • Loading branch information
jskeet committed Apr 14, 2022
1 parent df1a870 commit 591f83d
Show file tree
Hide file tree
Showing 13 changed files with 984 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ service ResourceNames {
rpc WildcardMultiPatternMultipleMethod(WildcardMultiPatternMultiple) returns(Response) {
option (google.api.method_signature) = "ref, repeated_ref"; // `name` parameter delibrately missing.
}

rpc LooseValidationPatternMethod(LooseValidationPattern) returns(Response) {
option (google.api.method_signature) = "name";
}
}

message SinglePattern {
Expand Down Expand Up @@ -91,4 +95,12 @@ message WildcardMultiPatternMultiple {
repeated string repeated_ref = 3 [(google.api.resource_reference).type = "resourcenames.example.com/WildcardMultiPatternMultiple"];
}

message LooseValidationPattern {
option (google.api.resource) = {
type: "resourcenames.example.com/LooseValidationPattern"
pattern: "parents/{parent_id}/invalid_name/items/{item_id}"
};
string name = 1;
}

message Response { }
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public ResourceNamesClient(CallInvoker callInvoker) { }
public virtual AsyncUnaryCall<Response> WildcardMultiPatternMethodAsync(WildcardMultiPattern request, CallOptions callOptions) => throw new NotImplementedException();
public virtual Response WildcardMultiPatternMultipleMethod(WildcardMultiPatternMultiple request, CallOptions callOptions) => throw new NotImplementedException();
public virtual AsyncUnaryCall<Response> WildcardMultiPatternMultipleMethodAsync(WildcardMultiPatternMultiple request, CallOptions callOptions) => throw new NotImplementedException();
public virtual Response LooseValidationPatternMethod(LooseValidationPattern request, CallOptions callOptions) => throw new NotImplementedException();
public virtual AsyncUnaryCall<Response> LooseValidationPatternMethodAsync(LooseValidationPattern request, CallOptions callOptions) => throw new NotImplementedException();
}
}

Expand Down Expand Up @@ -76,5 +78,10 @@ public partial class WildcardMultiPatternMultiple : ProtoMsgFake<WildcardMultiPa
public RepeatedField<string> RepeatedRef { get; } = new RepeatedField<string>();
}

public partial class LooseValidationPattern : ProtoMsgFake<LooseValidationPattern>
{
public string Name { get; set; }
}

public partial class Response : ProtoMsgFake<Response> { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Testing.ResourceNames.Snippets
{
// [START unknown_generated_ResourceNames_LooseValidationPatternMethod_async_flattened]
using System.Threading.Tasks;
using Testing.ResourceNames;

public sealed partial class GeneratedResourceNamesClientSnippets
{
/// <summary>Snippet for LooseValidationPatternMethodAsync</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public async Task LooseValidationPatternMethodAsync()
{
// Create client
ResourceNamesClient resourceNamesClient = await ResourceNamesClient.CreateAsync();
// Initialize request argument(s)
string name = "parents/[PARENT_ID]/invalid_name/items/[ITEM_ID]";
// Make the request
Response response = await resourceNamesClient.LooseValidationPatternMethodAsync(name);
}
}
// [END unknown_generated_ResourceNames_LooseValidationPatternMethod_async_flattened]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Testing.ResourceNames.Snippets
{
// [START unknown_generated_ResourceNames_LooseValidationPatternMethod_async]
using System.Threading.Tasks;
using Testing.ResourceNames;

public sealed partial class GeneratedResourceNamesClientSnippets
{
/// <summary>Snippet for LooseValidationPatternMethodAsync</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public async Task LooseValidationPatternMethodRequestObjectAsync()
{
// Create client
ResourceNamesClient resourceNamesClient = await ResourceNamesClient.CreateAsync();
// Initialize request argument(s)
LooseValidationPattern request = new LooseValidationPattern
{
LooseValidationPatternName = LooseValidationPatternName.FromParentItem("[PARENT_ID]", "[ITEM_ID]"),
};
// Make the request
Response response = await resourceNamesClient.LooseValidationPatternMethodAsync(request);
}
}
// [END unknown_generated_ResourceNames_LooseValidationPatternMethod_async]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Testing.ResourceNames.Snippets
{
// [START unknown_generated_ResourceNames_LooseValidationPatternMethod_sync]
using Testing.ResourceNames;

public sealed partial class GeneratedResourceNamesClientSnippets
{
/// <summary>Snippet for LooseValidationPatternMethod</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public void LooseValidationPatternMethodRequestObject()
{
// Create client
ResourceNamesClient resourceNamesClient = ResourceNamesClient.Create();
// Initialize request argument(s)
LooseValidationPattern request = new LooseValidationPattern
{
LooseValidationPatternName = LooseValidationPatternName.FromParentItem("[PARENT_ID]", "[ITEM_ID]"),
};
// Make the request
Response response = resourceNamesClient.LooseValidationPatternMethod(request);
}
}
// [END unknown_generated_ResourceNames_LooseValidationPatternMethod_sync]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Testing.ResourceNames.Snippets
{
// [START unknown_generated_ResourceNames_LooseValidationPatternMethod_async_flattened_resourceNames]
using System.Threading.Tasks;
using Testing.ResourceNames;

public sealed partial class GeneratedResourceNamesClientSnippets
{
/// <summary>Snippet for LooseValidationPatternMethodAsync</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public async Task LooseValidationPatternMethodResourceNamesAsync()
{
// Create client
ResourceNamesClient resourceNamesClient = await ResourceNamesClient.CreateAsync();
// Initialize request argument(s)
LooseValidationPatternName name = LooseValidationPatternName.FromParentItem("[PARENT_ID]", "[ITEM_ID]");
// Make the request
Response response = await resourceNamesClient.LooseValidationPatternMethodAsync(name);
}
}
// [END unknown_generated_ResourceNames_LooseValidationPatternMethod_async_flattened_resourceNames]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Testing.ResourceNames.Snippets
{
// [START unknown_generated_ResourceNames_LooseValidationPatternMethod_sync_flattened_resourceNames]
using Testing.ResourceNames;

public sealed partial class GeneratedResourceNamesClientSnippets
{
/// <summary>Snippet for LooseValidationPatternMethod</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public void LooseValidationPatternMethodResourceNames()
{
// Create client
ResourceNamesClient resourceNamesClient = ResourceNamesClient.Create();
// Initialize request argument(s)
LooseValidationPatternName name = LooseValidationPatternName.FromParentItem("[PARENT_ID]", "[ITEM_ID]");
// Make the request
Response response = resourceNamesClient.LooseValidationPatternMethod(name);
}
}
// [END unknown_generated_ResourceNames_LooseValidationPatternMethod_sync_flattened_resourceNames]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Testing.ResourceNames.Snippets
{
// [START unknown_generated_ResourceNames_LooseValidationPatternMethod_sync_flattened]
using Testing.ResourceNames;

public sealed partial class GeneratedResourceNamesClientSnippets
{
/// <summary>Snippet for LooseValidationPatternMethod</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public void LooseValidationPatternMethod()
{
// Create client
ResourceNamesClient resourceNamesClient = ResourceNamesClient.Create();
// Initialize request argument(s)
string name = "parents/[PARENT_ID]/invalid_name/items/[ITEM_ID]";
// Make the request
Response response = resourceNamesClient.LooseValidationPatternMethod(name);
}
}
// [END unknown_generated_ResourceNames_LooseValidationPatternMethod_sync_flattened]
}
Loading

0 comments on commit 591f83d

Please sign in to comment.