xemwebe / yahoo_finance_api

Simple wrapper to yahoo! finance API to retrieve latest quotes and end-of-day quote histories
Apache License 2.0
64 stars 29 forks source link

added a test, fixed issue #5 #6

Closed celaus closed 3 years ago

celaus commented 3 years ago

I know you fixed the conpat() call, but maybe the test I added would be valuable?

celaus commented 3 years ago

With this, the async tests could be skipped (but not the doctests unfortunately 😢 )

18:26:33 ~/w/yahoo_finance_api{blocking-api-bug-issue-5} 🌊  cargo test --features blocking
   Compiling yahoo_finance_api v1.0.0 (/Users/cm/workspace/yahoo_finance_api)
warning: unused import: `tokio_compat_02::FutureExt`
  --> src/lib.rs:70:5
   |
70 | use tokio_compat_02::FutureExt;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused import: `chrono::TimeZone`
   --> src/lib.rs:480:9
    |
480 |     use chrono::TimeZone;
    |         ^^^^^^^^^^^^^^^^

warning: unused import: `tokio_compat_02::FutureExt`
  --> src/lib.rs:70:5
   |
70 | use tokio_compat_02::FutureExt;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: 1 warning emitted

warning: 2 warnings emitted

    Finished test [unoptimized + debuginfo] target(s) in 4.03s
     Running target/debug/deps/yahoo_finance_api-0bac0c19315418d2

running 1 test
test tests::test_get_single_quote_blocking ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests yahoo_finance_api

running 3 tests
test src/lib.rs - (line 52) ... FAILED
test src/lib.rs - (line 14) ... FAILED
test src/lib.rs - (line 34) ... FAILED

failures: 

...
xemwebe commented 3 years ago

It would certainly be good to add this test. I believe it should be possible to apply feature gates also to code in comments, though I have to look up the exact syntax. And we would need to add examples using the blocking features in the documentation as well.

xemwebe commented 3 years ago

I have added an example and adjusted the doc code run with and without the blocking feature, therefore, I close this PR.