@@ -156,9 +156,32 @@ mod test {
156156 use super :: * ;
157157 use test_log:: test;
158158
159+ #[ test]
160+ fn test_command_builder_defaults ( ) {
161+ struct DefaultCommandBuilder {
162+ program_dir : Option < PathBuf > ,
163+ }
164+
165+ impl CommandBuilder for DefaultCommandBuilder {
166+ fn get_program ( & self ) -> & ' static OsStr {
167+ "test" . as_ref ( )
168+ }
169+
170+ fn get_program_dir ( & self ) -> & Option < PathBuf > {
171+ & self . program_dir
172+ }
173+ }
174+
175+ let builder = DefaultCommandBuilder { program_dir : None } ;
176+ let command = builder. build ( ) ;
177+
178+ assert_eq ! ( r#""test""# , command. to_command_string( ) ) ;
179+ }
180+
159181 struct TestCommandBuilder {
160182 program_dir : Option < PathBuf > ,
161183 args : Vec < OsString > ,
184+ envs : Vec < ( OsString , OsString ) > ,
162185 }
163186
164187 impl CommandBuilder for TestCommandBuilder {
@@ -173,18 +196,26 @@ mod test {
173196 fn get_args ( & self ) -> Vec < OsString > {
174197 self . args . clone ( )
175198 }
199+
200+ fn get_envs ( & self ) -> Vec < ( OsString , OsString ) > {
201+ self . envs . clone ( )
202+ }
176203 }
177204
178205 #[ test]
179206 fn test_standard_command_builder ( ) {
180207 let builder = TestCommandBuilder {
181208 program_dir : None ,
182209 args : vec ! [ "--help" . to_string( ) . into( ) ] ,
210+ envs : vec ! [ ( OsString :: from( "PASSWORD" ) , OsString :: from( "foo" ) ) ] ,
183211 } ;
184212 let command = builder. build ( ) ;
185213
186214 assert_eq ! (
187- format!( r#""{}" "--help""# , PathBuf :: from( "test" ) . to_string_lossy( ) ) ,
215+ format!(
216+ r#"PASSWORD="foo" "{}" "--help""# ,
217+ PathBuf :: from( "test" ) . to_string_lossy( )
218+ ) ,
188219 command. to_command_string( )
189220 ) ;
190221 }
@@ -195,11 +226,15 @@ mod test {
195226 let builder = TestCommandBuilder {
196227 program_dir : None ,
197228 args : vec ! [ "--help" . to_string( ) . into( ) ] ,
229+ envs : vec ! [ ( OsString :: from( "PASSWORD" ) , OsString :: from( "foo" ) ) ] ,
198230 } ;
199231 let command = builder. build_tokio ( ) ;
200232
201233 assert_eq ! (
202- format!( r#""{}" "--help""# , PathBuf :: from( "test" ) . to_string_lossy( ) ) ,
234+ format!(
235+ r#"PASSWORD="foo" "{}" "--help""# ,
236+ PathBuf :: from( "test" ) . to_string_lossy( )
237+ ) ,
203238 command. to_command_string( )
204239 ) ;
205240 }
0 commit comments