Cover client package with unit tests #108

Open
opened 2025-12-28 18:07:01 +00:00 by sami · 2 comments
Owner

Originally created by @cthulhu-rider on GitHub (Jun 15, 2022).

Testing of client package is pretty complex but necessary. We need to mock remote server and test Client on unit like

requestAssert - function which asserts the request received by the server
response - predefined response from the server to be returned
resultAssert - function which asserts that client return corresponds to the predefined server response

As the first task of the issue I propose to compose list of all test scenarios.

After the list of testcases is ready, there are at least two possible approaches of server mocking described below.

gRPC server with mocked handlers

We can serve gRPC server on some local endpoint and bind mocked handlers. Pros: no need to change the client. Cons: system resources (maybe it's possible to avoid system calls?).

Transport client as an interface

Hide internal client behind the interface and provide a way to change value for testing. Pros: gRPC is not needed at all. Cons: implementation changes.

Originally created by @cthulhu-rider on GitHub (Jun 15, 2022). Testing of `client` package is pretty complex but necessary. We need to mock remote server and test `Client` on unit like ``` requestAssert - function which asserts the request received by the server response - predefined response from the server to be returned resultAssert - function which asserts that client return corresponds to the predefined server response ``` As the first task of the issue I propose to compose list of all test scenarios. After the list of testcases is ready, there are at least two possible approaches of server mocking described below. ### gRPC server with mocked handlers We can serve gRPC server on some local endpoint and bind mocked handlers. Pros: no need to change the client. Cons: system resources (maybe it's possible to avoid system calls?). ### Transport client as an interface Hide internal client behind the interface and provide a way to change value for testing. Pros: gRPC is not needed at all. Cons: implementation changes.
Author
Owner

@cthulhu-rider commented on GitHub (Sep 20, 2022):

Started in #337. When testing other operations, it is worth considering a common test framework: most of the operations use the same scheme, but they differ in some ways.

@cthulhu-rider commented on GitHub (Sep 20, 2022): Started in #337. When testing other operations, it is worth considering a common test framework: most of the operations use the same scheme, but they differ in some ways.
Author
Owner

@gsmachado commented on GitHub (Sep 23, 2022):

❤️ 😍

@gsmachado commented on GitHub (Sep 23, 2022): ❤️ 😍
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-sdk-go#108
No description provided.