Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: enable testing for grpc-js #127

Closed
wants to merge 1 commit into from
Closed

test: enable testing for grpc-js #127

wants to merge 1 commit into from

Conversation

kjin
Copy link
Contributor

@kjin kjin commented Dec 18, 2017

do not review

This change re-writes some tests (as well as the any_grpc.js helper file) to test the pure js client against the native server. It should fail until a few pending PRs (#128, #131, #132, and two other future ones) are landed.

Skipped tests

Tests for Google credentials and deadline propagation are currently skipped for the JS client.

large removals in credentials_test.js and surface_test.js

The large removal in credentials_test.js is code I had previously copied into credentials_api_test.js and forgotten to delete.

The large removal in surface_test.js is what is now surface_server_test.js.

any_grpc.js

I've changed this file to export requireAs* and runAs* (* means either client or server) functions. The former functions as require but any nested calls to require('grpc') will be intercepted to return the relevant implementation instead. The latter simply takes a function and runs it with a single argument, which is the relevant grpc implementation. This is primarily useful for separating client and server implementations in the same scope, as I can turn

// fake api for illustrative purposes

const server = grpc.createServer();
// do something with server

const client = grpc.createClient();
// do something with client

into

// runAs* allows us to re-define 'grpc' in the scope of the passed callback

anyGrpc.runAsServer((grpc) => {
  const server = grpc.createServer();
  // do something with server
});

anyGrpc.runAsClient((grpc) => {
  const client = grpc.createClient();
  // do something with client
});

This allows us to change tests back to using require('grpc') and be relatively unencumbered by changes specific to dual implementations of grpc.

@kjin kjin closed this Mar 2, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant