We have a few tests for the Web API written in mocha.
The main reason why they were written in javascript in the first place was so that they would serve as documentation for whoever writes the frontend. However:
This makes maintaining them (a bit) harder.
Enabling the tests in the pipeline will also be a bit more troublesome.
The frontend will (probably) be written in Purescript, so it's not like having the api's tests in javascript helps that much.
I think we could still achieve our goal (documenting the web API) if we re-write the tests in Haskell, without using a servant client and without relying on coffer's data types/encoders/decoders. We could just write json literals in the tests (e.g. with aesonQQ), manually add the headers, etc.
These tests should:
Be written in a new test suite, coffer:test:server-integration
Spin up a couple of vault instances in Main before running the tests (just like scripts/run-bats-tests.sh).
Be independent of each other. For example, in the golden tests for the CLI (written in bats), we delete all entries in between tests.
Not step on each other's toes. E.g. we don't want two tests writing to/reading from the same vault instance at the same time, or we'll have race conditions everywhere. We basically have two options: (1) run the tests sequentially, or (2) spin up a new vault instance for each individual test. Let's keep it simple for now and just run the tests sequentially. We enforce this by setting the NumThreads option to 1 (and using localOption in Main).
Let's:
setup the test suite
create a makefile target for running the tests
enable the tests in the pipeline
write 1 or 2 tests just to prove that the setup works
We'll write the remaining tests in a separate issue
Acceptance criteria
We have a new test suite with a couple of tests
We have a makefile target for devs to easily run the tests
Clarification and motivation
We have a few tests for the Web API written in mocha.
The main reason why they were written in javascript in the first place was so that they would serve as documentation for whoever writes the frontend. However:
I think we could still achieve our goal (documenting the web API) if we re-write the tests in Haskell, without using a servant client and without relying on coffer's data types/encoders/decoders. We could just write json literals in the tests (e.g. with
aesonQQ
), manually add the headers, etc.These tests should:
coffer:test:server-integration
Main
before running the tests (just likescripts/run-bats-tests.sh
).bats
), we delete all entries in between tests.NumThreads
option to 1 (and usinglocalOption
inMain
).Let's:
We'll write the remaining tests in a separate issue
Acceptance criteria