lebe-dev / zabbix-api-rs

Zabbix API for Rust
MIT License
4 stars 2 forks source link

Doc-tests zabbix-api has error messages. #2

Closed tjyang closed 9 months ago

tjyang commented 9 months ago
-   Doc-tests zabbix-api has error messages.

$ pwd ~learnzabbix/zabbix-api-rs $ git log -1 commit d5fe2f41030a28459c814c365f958109e93b4d0f (HEAD -> main, origin/main, origin/HEAD) Author: Eugene Lebedev eugene.0x90@gmail.com Date: Fri Jan 26 13:58:18 2024 +0300

Add doc for get_hosts method

$ cargo test Finished test [unoptimized + debuginfo] target(s) in 0.09s Running unittests src/lib.rs (target/debug/deps/zabbix_api-4e0bec763865bf2f)

running 11 tests test client::v6::tests::create_host_group_and_host ... ok test client::v6::tests::get_api_info ... ok test client::v6::tests::get_host_groups_test ... ok test client::v6::tests::create_item ... ok test client::v6::tests::create_web_scenario ... ok test client::v6::tests::get_hosts_test ... ok test client::v6::tests::get_triggers_test ... ok test client::v6::tests::create_trigger ... ok test client::v6::tests::session_should_be_returned ... ok test client::v6::tests::get_webscenarios_test ... ok test client::v6::tests::raw_api_call_test ... ok

test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s

Doc-tests zabbix-api

running 1 test test src/client/v6/mod.rs - client::v6::ZabbixApiV6Client::get_hosts (line 225) ... FAILED

failures:

---- src/client/v6/mod.rs - client::v6::ZabbixApiV6Client::get_hosts (line 225) stdout ---- error[E0277]: the ? operator can only be used in a function that returns Result or Option (or another type that implements FromResidual) --> src/client/v6/mod.rs:248:57 4 fn main() { #[allow(non_snake_case)] fn _doctest_main_src_client_v6_mod_rs_225_0() { --------------------------------------------- this function should return Result or Option to accept ? ... 26 let session = client.get_auth_session("Admin", "zabbix")?; ^ cannot use the ? operator in a function that returns ()

= help: the trait FromResidual<Result<Infallible, ZabbixApiError>> is not implemented for ()

error[E0277]: the ? operator can only be used in a function that returns Result or Option (or another type that implements FromResidual) --> src/client/v6/mod.rs:249:49 4 fn main() { #[allow(non_snake_case)] fn _doctest_main_src_client_v6_mod_rs_225_0() { --------------------------------------------- this function should return Result or Option to accept ? ... 27 let hosts = client.get_hosts(&session, &request)?; ^ cannot use the ? operator in a function that returns ()

= help: the trait FromResidual<Result<Infallible, ZabbixApiError>> is not implemented for ()

error: aborting due to 2 previous errors

For more information about this error, try rustc --explain E0277. Couldn't compile the test.

failures: src/client/v6/mod.rs - client::v6::ZabbixApiV6Client::get_hosts (line 225)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.33s

error: doctest failed, to rerun pass --doc $

lebe-dev commented 9 months ago

Thanks for mention, i will fix this kind of errors at the release of v0.2.0. Now 0.2.0 is still in development phase. I'll close this issue after fix.

lebe-dev commented 9 months ago

Fixed