Skip to main content
Version: v3.x

Testing

So we have one more function to define, which is the query function, but before we do, let's talk about tests. The NDC specification repository provides a test runner executable called ndc-test, which can be used to implement a test suite for a connector.

We can also use ndc-test to run some automatic tests and validate the work we've done so far.

Back in your ndc-typescript-learn-course directory that we cloned during setup, you have a configuration.json file which you can use to run the connector against your sample database.

Now, let's run the tests. (You will need to have the ndc test runner installed on your machine.)

ndc-test test --endpoint http://localhost:8080

OR

cargo run --bin ndc-test -- test --endpoint http://localhost:8080

Some tests fail, but we expected them to fail, but we can already see that our schema response is good.

cargo run --bin ndc-test -- test --endpoint http://localhost:8080
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23s
Running `/Users/sean/ProjectsHasura/ndc-spec/target/debug/ndc-test test --endpoint 'http://localhost:8080'`

├ Capabilities ...
│ ├ Fetching /capabilities ... OK
│ ├ Validating capabilities ... OK
├ Schema ...
│ ├ Fetching schema ... OK
│ ├ Validating schema ...
│ │ ├ scalar_types ... OK
│ │ ├ object_types ... OK
│ │ ├ Collections ...
│ │ │ ├ albums ...
│ │ │ │ ├ Arguments ... OK
│ │ │ │ ├ Collection type ... OK
│ │ │ ├ artists ...
│ │ │ │ ├ Arguments ... OK
│ │ │ │ ├ Collection type ... OK
│ │ ├ Functions ...
│ │ │ ├ Procedures ...
├ Query ...
│ ├ albums ...
│ │ ├ Simple queries ...
│ │ │ ├ Select top N ... FAIL
│ ├ artists ...
│ │ ├ Simple queries ...
│ │ │ ├ Select top N ... FAIL
Failed with 2 test failures:

[1] Select top N
in Query
in albums
in Simple queries
in Select top N
Details: error communicating with the connector: error in response: status code 500 Internal Server Error

[2] Select top N
in Query
in artists
in Simple queries
in Select top N
Details: error communicating with the connector: error in response: status code 500 Internal Server Error

In the next section, we'll start to implement the query function, and see some of these tests pass.

Loading...