Skip to content

Split CLI and GRPC API tests #308

@CMCDragonkai

Description

@CMCDragonkai

Specification

It's time to split up the test modules for these areas, this will our test performance, and give us understanding of the test coverage of all our API behaviour:

  • tests/bin
  • tests/agent
  • tests/client

For tests/bin, each command can have its own test. Look at tests/bin/agent as a template for what to do. Right now all the other commands are single test modules in their own directory like tests/bin/identities/identities.test.ts. These should all be split up into individual commands. Note that most of the tests should be using the shared global agent. However some tests may be independent. This is where you can use the nested describe pattern as demonstrated in tests/bin/agent/status.test.ts.

Some tips:

  • Use the global shared agent
  • Use module mocking for prompting
  • Use the correct pkExec, pkStdio, pkSpawn, pkExpect utility
  • Use 1 nested describe at the bottom in case there is a need to use a the global shared agent and also have independent tests
  • Make sure to revert all side effects in the global shared agent! In every test!

We may optimise it further when realising that some tests can just use their own agent instead of sharing the agent. This is because by using the global keypair, starting agents is really fast now. This will probably need to be used in the nodes commands anyway.

For tests/agent and tests/client, this is about the GRPC API. We have now split up each RPC handler into their own file, this allows much more isolated and specific unit testing of each handler. Refer to tests/client/service/agentStop.test.ts as the template for each handler test. All rpc*.test.ts should be converted appropriately. Refer to #249 when you have questions or discussions about API design. This is just about splitting the tests up, however we may find we can fix things up regarding the API as this issue is tackled.

Additional context

Tasks

  1. Split up tests/bin
  2. Split up tests/client/service and refer to src/client/service and tests/client/service/agentStop.test.ts
  3. Split up tests/agent/service and refer to src/agent/service
  4. Check for other API conformance/design issues, such as error handling.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions