integration-tests
These tests run truss against definition files and tests if the generated code
behaves. Each test imports and uses service code generated by truss
, but that
code doesn't exist by default and must be generated before each test runs.
./transport
The transport
directory contains tests for ensuring the generated HTTP client
libraries and the generated gRPC client libraries all correctly communicate
over their particular transport. Additionally, there are tests using the
standard standard Go net/http
module to ensure that HTTP transport operates
in a sane way, even for requests not made with the generated HTTP client.
The test harness works as follows:
- Runs truss against
transport/transport-test.proto
, which generates transport/transportpermutations-service
- Copy
transport/handlers
into transport/transportpermutations-service
- Run
go test -v
- Runs truss again against
transport/transport-test.proto
(for regeneration tests)
- Run
go test -v
transport/handlers
has implemented handlers for the server. These test
handlers implement some very basic functionality for the purposes of testing.
This functionality is to 'add' various things together; concatenating two
strings and returning the concatenated string, or adding two numbers together
and returning the addition.
transport/setup_test.go
sets up HTTP and gRPC servers with the methods for
the test. Then each transport/{TRANSPORT}_test.go
imports the generated code,
runs requests against the server, checking for errors and that the input values
add to the expected output value(s).
./middlewares
middlewares
is very similar to transport, having prewritten handlers and
middlewares, it generates a truss service and copies these into that service.
Then it runs tests against the endpoints (avoiding the transport logic) to see
if middlewares were correctly applied and/or excluded from the endpoints.
./cli
The truss CLI integration runner does the following tasks:
- Runs truss on each service definition in
cli/test_service_definitions
- Builds the server and CLI client for each service
- Runs the generated server
- Runs the generated CLI client against the generated server
- Passes if the server and CLI client were able to communicate. Fails if there
were errors of any kind.
Note also that any additional CLI integration tests must have a package name
TEST
, all letters uppercase.