Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schemer-rusqlite: update doc example; exposes error #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nathan-at-least
Copy link

Rationale

Ensure doc example uses modern rust, is automatically tested, and checks for errors.

Summary

This PR updates the schemer-rusqlite doc example in three ways:

  • It drops the extern crate and #[macro_use] statements to follow edition 2021 style.
  • It moves the body of main to the top-level: this is very important because it ensure cargo test exercises the expressions.
  • It calls unwrap on all results: this exposes an error!

Exposed Error

$ cargo test -p schemer-rusqlite                                                                                                                                                                                   
    Finished test [unoptimized + debuginfo] target(s) in 0.03s                                                                                                                                                     
     Running unittests src/lib.rs (target/debug/deps/schemer_rusqlite-c8c258f066245d88)                                                                                                                            
                                                                                                                                                                                                                   
running 4 tests                                                                                                                                                                                                    
test tests::test_migration_chain ... ok                                                                                                                                                                            
test tests::test_single_migration ... ok                                                                                                                                                                           
test tests::test_branching_dag ... ok                                                                    
test tests::test_multi_component_dag ... ok                                                                                                                                                                        
                                                                                                         
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s                                                                                                                      
                                                                                                         
   Doc-tests schemer-rusqlite                                                                                                                                                                                      
                                                                                                         
running 2 tests                                                                                                                                                                                                    
test src/lib.rs - RusqliteAdapter<'a,E>::new (line 97) ... ok
test src/lib.rs - (line 6) ... FAILED                                                                                                                                                                              
                                                                                                         
failures:                                                                                                                                                                                                          
                                                                                                         
---- src/lib.rs - (line 6) stdout ----                                                                                                                                                                             
Test executable failed (exit status: 101).
stderr:                                                                                                                                                                                                   [39/1145]
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Adapter(SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("no such table: _schemer")))', src/lib.rs:40:19
stack backtrace: 
[… backtrace elided]

failures:                                                                                                
    src/lib.rs - (line 6)                                                                                                                                                                                          
                                                                                                         
test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.74s                                                                                                                  
                                                                                                         
error: doctest failed, to rerun pass `-p schemer-rusqlite --doc`          

Rendering

The rendered docs now look like this on my system:
image

…e to modern rust; unwrapping `Result` shows `no such table: _schemer` error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant