Skip to content

Conversation

@glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Jun 29, 2020

Motivation:

When consuming gRPC it is often helpful to be able to write tests that
ensure the client is integrated correctly. At the moment this is only
possible by running a local gRPC server with a custom service handler to
return the responses you would like to test.

Modifications:

This is a continuation of the work started in #855.

  • This change addes a 'FakeChannel' this is the glue that binds the Call
    objects with the 'fake responses' added in the aforementioned pull
    request.
  • Also adds a 'write capturing' handler which forwards request parts to
    a handler provided on the fake response.
  • Appropriate internal initializers on each of the call types.

Result:

  • Users can manually create 'test' RPCs.

This change is Reviewable

Motivation:

When consuming gRPC it is often helpful to be able to write tests that
ensure the client is integrated correctly. At the moment this is only
possible by running a local gRPC server with a custom service handler to
return the responses you would like to test.

Modifications:

This is a continuation of the work started in grpc#855.

- This change addes a 'FakeChannel' this is the glue that binds the Call
  objects with the 'fake responses' added in the aforementioned pull
  request.
- Also adds a 'write capturing' handler which forwards request parts to
  a handler provided on the fake response.
- Appropriate internal initializers on each of the call types.

Result:

- Users can manually create 'test' RPCs.
@glbrntt glbrntt added kind/enhancement Improvements to existing feature. nio 🆕 semver/minor Adds new public API. labels Jun 29, 2020
@glbrntt glbrntt requested review from Lukasa and MrMage June 29, 2020 15:23
Copy link
Collaborator

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I love this. This is a really nice patch. I'll let @MrMage review as well.

Copy link
Collaborator

@MrMage MrMage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to add from my side :-)

@glbrntt glbrntt merged commit 2732990 into grpc:master Jun 30, 2020
@glbrntt glbrntt deleted the gb-fake-channel branch June 30, 2020 12:13
glbrntt added a commit to glbrntt/grpc-swift that referenced this pull request Jul 1, 2020
Motivation:

When consuming gRPC it is often helpful to be able to write tests that
ensure the client is integrated correctly. At the moment this is only
possible by running a local gRPC server with a custom service handler to
return the responses you would like to test.

Modifications:

This builds on work in grpc#855, grpc#864, and grpc#865.

This pull request introduces code generation for the test clients. It
provides type-safe wrappers and convenience methods on top of
`FakeChannel` and a code-gen option to enable 'TestClient' generation.

It also removes an `init` requirement on the `GRPCClient` protocol.

Result:

Users can generate test clients.
glbrntt added a commit to glbrntt/grpc-swift that referenced this pull request Jul 1, 2020
Motivation:

When consuming gRPC it is often helpful to be able to write tests that
ensure the client is integrated correctly. At the moment this is only
possible by running a local gRPC server with a custom service handler to
return the responses you would like to test.

Modifications:

This builds on work in grpc#855, grpc#864, and grpc#865.

This pull request introduces code generation for the test clients. It
provides type-safe wrappers and convenience methods on top of
`FakeChannel` and a code-gen option to enable 'TestClient' generation.

It also removes an `init` requirement on the `GRPCClient` protocol.

Result:

Users can generate test clients.
glbrntt added a commit to glbrntt/grpc-swift that referenced this pull request Jul 2, 2020
Motivation:

When consuming gRPC it is often helpful to be able to write tests that
ensure the client is integrated correctly. At the moment this is only
possible by running a local gRPC server with a custom service handler to
return the responses you would like to test.

Modifications:

This builds on work in grpc#855, grpc#864, and grpc#865.

This pull request introduces code generation for the test clients. It
provides type-safe wrappers and convenience methods on top of
`FakeChannel` and a code-gen option to enable 'TestClient' generation.

It also removes an `init` requirement on the `GRPCClient` protocol.

Result:

Users can generate test clients.
MrMage pushed a commit that referenced this pull request Jul 3, 2020
* Provide the codegen with an option to generate test clients

Motivation:

When consuming gRPC it is often helpful to be able to write tests that
ensure the client is integrated correctly. At the moment this is only
possible by running a local gRPC server with a custom service handler to
return the responses you would like to test.

Modifications:

This builds on work in #855, #864, and #865.

This pull request introduces code generation for the test clients. It
provides type-safe wrappers and convenience methods on top of
`FakeChannel` and a code-gen option to enable 'TestClient' generation.

It also removes an `init` requirement on the `GRPCClient` protocol.

Result:

Users can generate test clients.

* Regenerate

* fix type, add assertion

* Add "Remaining"
@glbrntt glbrntt mentioned this pull request Jul 3, 2020
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement Improvements to existing feature. 🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants