File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ It then attaches comments to the SQL structures they describe.
1313## Example
1414
1515With a directory structured like this:
16- ```
16+ ``` bash
1717sql_dir/
1818└── users.sql
1919```
@@ -30,7 +30,7 @@ CREATE TABLE users (
3030);
3131```
3232A rudimentary implementation can be generated with:
33- ``` rust
33+ ``` rust,no_run
3434use sql_docs::generate_docs_from_dir_no_deny;
3535use std::path::Path;
3636
Original file line number Diff line number Diff line change @@ -378,4 +378,5 @@ mod tests {
378378 }
379379 }
380380 }
381+
381382}
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ impl DenyList {
2828}
2929
3030/// A collection of discovered `.sql` files under a given directory.
31+ #[ derive( Debug ) ]
3132pub struct SqlFilesList {
3233 sql_files : Vec < PathBuf > ,
3334}
@@ -281,4 +282,28 @@ mod tests {
281282 assert_eq ! ( found, expected) ;
282283 let _ = fs:: remove_dir_all ( & base) ;
283284 }
285+
286+ #[ test]
287+ fn test_file_fails ( ) {
288+ let invalid_dir = "INVALID" ;
289+ let failed_list = SqlFilesList :: new ( invalid_dir, None ) ;
290+ assert ! ( failed_list. is_err( ) ) ;
291+
292+ let base = env:: temp_dir ( ) . join ( "test_files_fails_dir" ) ;
293+ let _ = fs:: remove_dir_all ( & base) ;
294+ fs:: create_dir_all ( & base) . unwrap ( ) ;
295+ let bad_file = base. join ( "one.sql" ) ;
296+ fs:: File :: create ( & bad_file) . unwrap ( ) ;
297+ let failed_read = SqlFilesList :: new ( & bad_file, None ) ;
298+ assert ! ( failed_read. is_err( ) ) ;
299+ let missed_file = base. join ( "missing.sql" ) ;
300+ let missing_file = SqlFile :: new ( & missed_file) ;
301+ assert ! ( missing_file. is_err( ) ) ;
302+ let _ = fs:: remove_dir_all ( & base) ;
303+
304+ let bad_file_list = SqlFileSet :: new ( Path :: new ( invalid_dir) , None ) ;
305+ assert ! ( bad_file_list. is_err( ) )
306+
307+ }
284308}
309+
Original file line number Diff line number Diff line change @@ -87,9 +87,9 @@ impl From<ParserError> for DocError {
8787/// sql parsing)
8888///
8989/// # Example
90- /// ```no_run
90+ /// ```rust, no_run
9191/// use sql_docs::generate_docs_from_dir;
92- /// let docs = generate_docs_from_dir("sql_dir", &["skip_this.sql"])? ;
92+ /// let docs = generate_docs_from_dir("sql_dir", &["skip_this.sql"]);
9393/// ```
9494pub fn generate_docs_from_dir < P : AsRef < Path > , S : AsRef < str > > (
9595 dir : P ,
@@ -126,9 +126,9 @@ pub fn generate_docs_from_dir<P: AsRef<Path>, S: AsRef<str>>(
126126/// sql parsing)
127127///
128128/// # Example
129- /// ```no_run
130- /// use sql_docs::generate_docs_from_dir ;
131- /// let docs = generate_docs_from_dir_no_deny("sql_dir")? ;
129+ /// ```rust, no_run
130+ /// use sql_docs::generate_docs_from_dir_no_deny ;
131+ /// let docs = generate_docs_from_dir_no_deny("sql_dir");
132132/// ```
133133pub fn generate_docs_from_dir_no_deny < P : AsRef < Path > > (
134134 dir : P ,
You can’t perform that action at this time.
0 commit comments