xmtp / didethresolver

XMTP Registry Resolver
MIT License
3 stars 1 forks source link

eliminate warning for unused method during testing #20

Closed tsachiherman closed 9 months ago

tsachiherman commented 9 months ago

What's the problem ?

Running cargo test generated the following warning:

warning: static `INIT` is never used
 --> tests/integration_util/mod.rs:6:8
  |
6 | static INIT: Once = Once::new();
  |        ^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: function `init_logging` is never used
 --> tests/integration_util/mod.rs:8:15
  |
8 | pub(crate) fn init_logging() {
  |               ^^^^^^^^^^^^

warning: `didethresolver` (test "integration_test") generated 2 warnings

Why does that happen ?

We currently have no integration tests implemented. In fact, we have a single stub called test_resolve_did that have a single like of code :

todo!()

As a result of that, the init_logging and the INIT aren't being used.

Solution

Modify the test_resolve_did() implementation, and add a call to init_logging. This would eliminate the warning, as the method would be called.

Note

This PR is identical to the previous one ( https://github.com/xmtp/didethresolver/pull/19 ), but made with a verified committing user.

insipx commented 9 months ago

Integration tests were added in the latest PR, but if it is still an issue, the init_logging function is used in only non-test environments. It can be annotated with #cfg[not(test)] to only compile the method in these cases.

__init_logging will be instantiated for all tests w/ ctor, so it does not require calling it within each test

tsachiherman commented 9 months ago

Integration tests were added in the latest PR, but if it is still an issue, the init_logging function is used in only non-test environments. It can be annotated with #cfg[not(test)] to only compile the method in these cases.

__init_logging will be instantiated for all tests w/ ctor, so it does not require calling it within each test

correct. with your PR, this one is no longer needed.