@@ -71,7 +71,7 @@ fn test_config_commands() {
7171
7272 // Set receive directory
7373 let mut cmd = cargo_bin_cmd ! ( "arkdrop-cli" ) ;
74- cmd. args ( [ "config" , "set-receive-dir " , temp_path] )
74+ cmd. args ( [ "config" , "set-output " , temp_path] )
7575 . assert ( )
7676 . success ( ) ;
7777
@@ -84,160 +84,21 @@ fn test_config_commands() {
8484
8585 // Clear receive directory
8686 let mut cmd = cargo_bin_cmd ! ( "arkdrop-cli" ) ;
87- cmd. args ( [ "config" , "clear-receive-dir " ] )
87+ cmd. args ( [ "config" , "clear-output " ] )
8888 . assert ( )
8989 . success ( ) ;
9090}
9191
92- /// Test send command with valid files (should fail at connection stage)
92+ /// Test receive command parameter validation
9393#[ test]
94- fn test_send_valid_files ( ) {
95- let temp_dir = TempDir :: new ( ) . expect ( "Failed to create temp directory" ) ;
96- let file_path = temp_dir. path ( ) . join ( "test.txt" ) ;
97- std:: fs:: write ( & file_path, "test content" )
98- . expect ( "Failed to create test file" ) ;
99-
100- // This should fail because there's no receiver, but it should validate the
101- // file first
94+ fn test_receive_parameters ( ) {
10295 let mut cmd = cargo_bin_cmd ! ( "arkdrop-cli" ) ;
103- cmd. args ( [ "send " , file_path . to_str ( ) . unwrap ( ) ] )
96+ cmd. args ( [ "receive " , "test-ticket" , "123" , "--name" , "test-receiver" ] )
10497 . assert ( )
105- . code ( predicate:: ne ( 0 ) )
10698 . stdout (
107- predicate:: str:: contains ( "Preparing to send" )
108- . or ( predicate:: str:: contains ( "file(s)" ) )
109- . or ( predicate:: str:: contains ( "ticket" ) )
110- . or ( predicate:: str:: contains ( "confirmation" ) ) ,
111- ) ;
112- }
113-
114- /// Test CLI handles file validation correctly
115- #[ test]
116- fn test_file_validation ( ) {
117- let temp_dir = TempDir :: new ( ) . expect ( "Failed to create temp directory" ) ;
118-
119- // Create test files
120- let valid_file = temp_dir. path ( ) . join ( "valid.txt" ) ;
121- std:: fs:: write ( & valid_file, "valid content" )
122- . expect ( "Failed to create valid file" ) ;
123-
124- // Test with valid file - should pass validation, fail at connection
125- let mut cmd = cargo_bin_cmd ! ( "arkdrop-cli" ) ;
126- cmd. args ( [
127- "send" ,
128- "--name" ,
129- "test-sender" ,
130- valid_file. to_str ( ) . unwrap ( ) ,
131- ] )
132- . assert ( )
133- . stdout (
134- predicate:: str:: contains ( "Preparing to send" )
135- . or ( predicate:: str:: contains ( "valid.txt" ) )
136- . or ( predicate:: str:: contains ( "Sender name" ) ) ,
137- ) ;
138-
139- // Test with nonexistent file - should fail validation
140- let mut cmd = cargo_bin_cmd ! ( "arkdrop-cli" ) ;
141- cmd. args ( [ "send" , "--name" , "test-sender" , "nonexistent.txt" ] )
142- . assert ( )
143- . failure ( )
144- . stderr (
145- predicate:: str:: contains ( "File does not exist" )
146- . or ( predicate:: str:: contains ( "not found" ) ) ,
99+ predicate:: str:: contains ( "Preparing to receive" )
100+ . or ( predicate:: str:: contains ( "test-ticket" ) )
101+ . or ( predicate:: str:: contains ( "Receiver name" ) )
102+ . or ( predicate:: str:: contains ( "Output directory" ) ) ,
147103 ) ;
148104}
149-
150- /// Test receive command parameter validation
151- #[ test]
152- fn test_receive_parameters ( ) {
153- let temp_dir = TempDir :: new ( ) . expect ( "Failed to create temp directory" ) ;
154- let output_path = temp_dir. path ( ) . to_str ( ) . unwrap ( ) ;
155-
156- // Test with all required parameters - should attempt connection and fail
157- let mut cmd = cargo_bin_cmd ! ( "arkdrop-cli" ) ;
158- cmd. args ( [
159- "receive" ,
160- "test-ticket" ,
161- "123" ,
162- "--output" ,
163- output_path,
164- "--name" ,
165- "test-receiver" ,
166- ] )
167- . assert ( )
168- . stdout (
169- predicate:: str:: contains ( "Preparing to receive" )
170- . or ( predicate:: str:: contains ( "test-ticket" ) )
171- . or ( predicate:: str:: contains ( "Receiver name" ) )
172- . or ( predicate:: str:: contains ( "Output directory" ) ) ,
173- ) ;
174- }
175-
176- /// Test avatar handling
177- #[ test]
178- fn test_avatar_options ( ) {
179- let temp_dir = TempDir :: new ( ) . expect ( "Failed to create temp directory" ) ;
180- let avatar_file = temp_dir. path ( ) . join ( "avatar.png" ) ;
181- let test_file = temp_dir. path ( ) . join ( "test.txt" ) ;
182-
183- // Create dummy files
184- std:: fs:: write ( & avatar_file, b"fake image data" )
185- . expect ( "Failed to create avatar file" ) ;
186- std:: fs:: write ( & test_file, "test content" )
187- . expect ( "Failed to create test file" ) ;
188-
189- // Test with avatar file
190- let mut cmd = cargo_bin_cmd ! ( "arkdrop-cli" ) ;
191- cmd. args ( [
192- "send" ,
193- "--name" ,
194- "avatar-sender" ,
195- "--avatar" ,
196- avatar_file. to_str ( ) . unwrap ( ) ,
197- test_file. to_str ( ) . unwrap ( ) ,
198- ] )
199- . assert ( )
200- . stdout (
201- predicate:: str:: contains ( "Avatar: Set" )
202- . or ( predicate:: str:: contains ( "avatar-sender" ) ) ,
203- ) ;
204-
205- // Test with base64 avatar
206- let mut cmd = cargo_bin_cmd ! ( "arkdrop-cli" ) ;
207- cmd. args ( [
208- "send" ,
209- "--name" ,
210- "b64-sender" ,
211- "--avatar-b64" ,
212- "dGVzdA==" ,
213- test_file. to_str ( ) . unwrap ( ) ,
214- ] )
215- . assert ( )
216- . stdout (
217- predicate:: str:: contains ( "Avatar: Set" )
218- . or ( predicate:: str:: contains ( "b64-sender" ) ) ,
219- ) ;
220- }
221-
222- /// Test verbose flag
223- #[ test]
224- fn test_verbose_flag ( ) {
225- let temp_dir = TempDir :: new ( ) . expect ( "Failed to create temp directory" ) ;
226- let test_file = temp_dir. path ( ) . join ( "test.txt" ) ;
227- std:: fs:: write ( & test_file, "test content" )
228- . expect ( "Failed to create test file" ) ;
229-
230- let mut cmd = cargo_bin_cmd ! ( "arkdrop-cli" ) ;
231- cmd. args ( [
232- "send" ,
233- "--verbose" ,
234- "--name" ,
235- "verbose-sender" ,
236- test_file. to_str ( ) . unwrap ( ) ,
237- ] )
238- . assert ( )
239- . stdout (
240- predicate:: str:: contains ( "verbose-sender" )
241- . or ( predicate:: str:: contains ( "Preparing to send" ) ) ,
242- ) ;
243- }
0 commit comments