File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -186,3 +186,36 @@ pub fn execute(_args: &ArgMatches) -> Result<()> {
186186
187187 Ok ( ( ) )
188188}
189+
190+ #[ test]
191+ fn test_parse_toml ( ) {
192+ let toml = r#"
193+ root_url_prefix = "myprefix"
194+
195+ [[book]]
196+ git_url = "firsturl"
197+ git_ref = "shelf"
198+ path = "guide"
199+
200+ [[book]]
201+ git_url = "secondurl"
202+
203+ [[book]]
204+ path = "../test_book"
205+ "# ;
206+ let cfg: Shelf = toml:: from_str ( & toml) . unwrap ( ) ;
207+ assert_eq ! ( cfg. root_url_prefix. unwrap( ) , "myprefix" ) ;
208+
209+ let book = & cfg. book [ 0 ] ;
210+ assert_eq ! ( book. git_url. clone( ) . unwrap( ) , "firsturl" ) ;
211+ assert_eq ! ( book. git_ref. clone( ) . unwrap( ) , "shelf" ) ;
212+ assert_eq ! ( book. path. clone( ) . unwrap( ) , "guide" ) ;
213+
214+ let book = & cfg. book [ 1 ] ;
215+ assert_eq ! ( book. git_url. clone( ) . unwrap( ) , "secondurl" ) ;
216+ assert ! ( book. git_ref. is_none( ) ) ;
217+ assert ! ( book. path. is_none( ) ) ;
218+
219+ let book = & cfg. book [ 2 ] ;
220+ assert_eq ! ( book. path. clone( ) . unwrap( ) , "../test_book" ) ;
221+ }
You can’t perform that action at this time.
0 commit comments