Sha256: 4f5d24626f4e87312cf6b6bbe4cbbc79f87d4c987477dff432db1f3bfbe16898

Contents?: true

Size: 1014 Bytes

Versions: 1

Compression:

Stored size: 1014 Bytes

Contents

require 'integration_spec_helper'

describe 'File integrity over upload/download operations' do

  if account_file_exists?

    before(:all) do
      @storage = login
    end

    let(:name) { "test_file" }

    let(:path) { File.join(temp_folder, name)}

    [12, 1_024_000].each do |size|

      context "when a file (#{size} bytes) is uploaded and then downloaded" do

        let(:content) { OpenSSL::Random.random_bytes(size) }

        let(:content_hash) { Digest::MD5.hexdigest(content) }

        before do
          File.open(path, 'wb') { |f| f.write(content) }
          file = @storage.root.upload(path)
          @file = @storage.nodes.find { |n| n.handle == file.handle }
          expect(@file.name).to eq(name)
          @file.download(path+".downloaded")
        end

        it 'it does not get corrupted' do
          expect(Digest::MD5.file(path+".downloaded").hexdigest).to eq(content_hash)
        end

        after do
          @file.delete if @file
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rmega-0.2.0 spec/integration/file_integrity_spec.rb