Sha256: c803ce1634c94bb3914b67bcade3ed46b74c5b2809b9e0cd4110c87263ac6d35

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

require 'integration_spec_helper'

describe 'File integrity' do

  if account?

    before(:all) do
      @storage = login
    end

    context "when a file is renamed" do

      let(:path) { "#{temp_folder}/testfile_#{SecureRandom.hex(6)}" }

      let(:new_name) { "testfile_#{SecureRandom.hex(6)}" }

      it 'it does not get corrupted' do
        File.write(path, SecureRandom.hex(24))
        file = @storage.root.upload(path)
        file.rename(new_name)
        expect(file.name).to eq(new_name)
        file = @storage.nodes.find { |n| n.handle == file.handle }
        file.delete
        expect(file.name).to eq(new_name)
      end
    end

    [12, 6_000].each do |size|

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

        let(:path) { "#{temp_folder}/testfile_#{SecureRandom.hex(6)}" }

        let(:content) { SecureRandom.random_bytes(size) }

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

        it 'it does not get corrupted' do
          File.write(path, content)
          file = @storage.root.upload(path)
          file.download("#{path}.downloaded")
          file.delete
          expect(Digest::MD5.file("#{path}.downloaded").hexdigest).to eq(content_hash)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rmega-0.3.2 spec/integration/file_integrity_spec.rb
rmega-0.3.1 spec/integration/file_integrity_spec.rb
rmega-0.2.7 spec/integration/file_integrity_spec.rb
rmega-0.2.6 spec/integration/file_integrity_spec.rb
rmega-0.2.5 spec/integration/file_integrity_spec.rb
rmega-0.2.4 spec/integration/file_integrity_spec.rb
rmega-0.2.2 spec/integration/file_integrity_spec.rb
rmega-0.2.1 spec/integration/file_integrity_spec.rb