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. Let's compile and run
our connector, and then use the test runner with the running connector.
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:8100
OR
cargo run --bin ndc-test -- test --endpoint http://localhost:8100
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:8100Finished dev [unoptimized + debuginfo] target(s) in 0.21sRunning `/Users/me/ndc-spec/target/debug/ndc-test test --endpoint 'http://localhost:8100'`├ Capabilities ...│ ├ Fetching /capabilities ... OK│ ├ Validating capabilities ... OK├ Schema ...│ ├ Fetching schema ... OK│ ├ Validating schema ...│ │ ├ 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│ │ ├ Aggregate queries ...│ │ │ ├ star_count ... FAIL│ ├ artists ...│ │ ├ Simple queries ...│ │ │ ├ Select top N ... FAIL│ │ ├ Aggregate queries ...│ │ │ ├ star_count ... FAIL
In the next section, we'll start to implement the query function, and see some of these tests pass.
- Build apps and APIs 10x faster
- Built-in authorization and caching
- 8x more performant than hand-rolled APIs