test/integration/rapidshare-ext_test.rb in rapidshare-ext-0.0.5 vs test/integration/rapidshare-ext_test.rb in rapidshare-ext-0.0.6

- old
+ new

@@ -15,10 +15,14 @@ File.delete "#@download_dir/upload_file_1.txt" if File.exist? "#@download_dir/upload_file_1.txt" @upload_file_1 = File.expand_path(File.dirname(__FILE__) + "/../fixtures/files/upload1.txt") @upload_file_1_md5 = Digest::MD5.hexdigest(File.read(@upload_file_1)) @upload_file_1_size = File.size @upload_file_1 + + @upload_file_2 = File.expand_path(File.dirname(__FILE__) + "/../fixtures/files/upload2.txt") + @upload_file_2_md5 = Digest::MD5.hexdigest(File.read(@upload_file_2)) + @upload_file_2_size = File.size @upload_file_2 end context "Api" do should "upload file" do upload_assertion = ->(resp, size_local, digest_local, remote_filename) do @@ -56,12 +60,21 @@ assert_equal info[:md5hex].downcase, @upload_file_1_md5 assert_equal info[:realfolder].to_i, @rs.folder_id(remote_dir) # Upload the same file again response = @rs.upload @upload_file_1, :to => remote_dir, :as => remote_filename - upload_assertion.call response, @upload_file_1_size, @upload_file_1_md5, remote_filename assert_true response[:already_exists?] + upload_assertion.call response, @upload_file_1_size, @upload_file_1_md5, remote_filename + + # Upload another file under the same path but with overwriting the existing one + response = @rs.upload @upload_file_2, + :to => remote_dir, + :as => remote_filename, + :overwrite => true + + assert_false response[:already_exists?] + upload_assertion.call response, @upload_file_2_size, @upload_file_2_md5, remote_filename end should "download file" do @rs.upload @upload_file_1, :to => "/a/b/c", :as => "upload_file_1.txt" assert_not_nil @rs.file_info("/a/b/c/upload_file_1.txt") @@ -352,9 +365,12 @@ msg = "Directory tree consistency error. Parent folder ##{folder_a_id} for the folder \"/<undefined>/b\" [#{folder_b_id}] could not be found" assert_raise_message(msg) do @rs.reload! :validate => true end + + # Remedy + @rs.erase_all_data! end end end