Skip to content

Commit

Permalink
tests: Streamline testing for LRO
Browse files Browse the repository at this point in the history
- Disable testing of snippets rather than having all the files with "test disabled"
- Remove the build test (which would require us to have snippet csproj files)
- Move the fakes out of the folder where we expect generated code to live
- Test against the full generated file instead of just small parts of it
  • Loading branch information
jskeet committed May 22, 2024
1 parent a7edb89 commit 69ae172
Show file tree
Hide file tree
Showing 20 changed files with 515 additions and 120 deletions.
5 changes: 1 addition & 4 deletions Google.Api.Generator.Tests/ProtoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void CleanUp(string path)
public void Paginated0() => ProtoTestSingle("Paginated", ignoreCsProj: true);

[Fact]
public void Lro0() => ProtoTestSingle("Lro");
public void Lro0() => ProtoTestSingle("Lro", ignoreSnippets: true);

[Fact]
public void ServerStreaming0() => ProtoTestSingle("ServerStreaming", ignoreCsProj: true, ignoreSnippets: true);
Expand Down Expand Up @@ -365,9 +365,6 @@ public void PublishingSettings() => ProtoTestSingle(
[Fact]
public void BuildBasic() => BuildTest("Basic", protoPackageVersion: "v1");

[Fact]
public void BuildLro() => BuildTest("Lro");

[Fact]
public void DuplicateResourceDefinitions()
{
Expand Down
1 change: 1 addition & 0 deletions Google.Api.Generator.Tests/ProtoTests/Lro/Lro.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "google/api/resource.proto";

package testing.lro;

// LRO service to test.
service Lro {
option (google.api.default_host) = "lro.example.com";

Expand Down
66 changes: 66 additions & 0 deletions Google.Api.Generator.Tests/ProtoTests/Lro/LroFakes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2019 Google Inc. All Rights Reserved.
//
// 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.

using Google.LongRunning;
using Google.Protobuf.Reflection;
using Grpc.Core;
using System;

// Disable warning: Missing XML comment on public members.
// Required to successfully build this generated test project.
#pragma warning disable 1591

namespace Testing.Lro;

// gRPC fakes
public static partial class Lro
{
public static ServiceDescriptor Descriptor => null;
public partial class LroClient
{
private CallInvoker CallInvoker => throw new NotImplementedException();

public LroClient(CallInvoker callInvoker) { }
public virtual AsyncUnaryCall<Operation> SignatureMethodAsync(Request request, CallOptions options) => throw new NotImplementedException();
public virtual Operation SignatureMethod(Request request, CallOptions options) => throw new NotImplementedException();
public virtual AsyncUnaryCall<Operation> ResourcedMethodAsync(ResourceRequest request, CallOptions options) => throw new NotImplementedException();
public virtual Operation ResourcedMethod(ResourceRequest request, CallOptions options) => throw new NotImplementedException();
}
}

// Protobuf fakes
public class Request : ProtoMsgFake<Request>
{
public string Name { get; set; }
}

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

public class LroResponse : ProtoMsgFake<LroResponse> {
public class Types
{
public class Nested : ProtoMsgFake<Nested> { }
}
}

public class LroMetadata : ProtoMsgFake<LroMetadata>
{
public class Types
{
public class Nested : ProtoMsgFake<Nested> { }
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 69ae172

Please sign in to comment.