Sha256: e9a37ee01397e2d72b29c33eb30323c63facd2911eec1888d51db9a5823808f9

Contents?: true

Size: 970 Bytes

Versions: 10

Compression:

Stored size: 970 Bytes

Contents

require_relative 'test_helper'

class S3ReaderTest < Minitest::Test
  describe IOStreams::File::Reader do
    let :file_name do
      File.join(File.dirname(__FILE__), 'files', 'text.txt')
    end

    let :raw do
      File.read(file_name)
    end

    let :uri do
      "s3://#{ENV['S3_BUCKET_NAME']}/s3_test/test.txt"
    end

    let :upload_s3_file do
      IOStreams::S3::Writer.open(uri) { |io| io << raw }
    end

    describe '.open' do
      it 'reads' do
        unless ENV['S3_BUCKET_NAME']
          skip "Supply 'S3_BUCKET_NAME' environment variable with S3 bucket name to test with"
        end

        upload_s3_file
        result = IOStreams::S3::Reader.open(uri) { |io| io.read }
        assert_equal raw, result
      end

      it 'does not support streams' do
        io_string = StringIO.new('data')
        assert_raises ArgumentError do
          IOStreams::S3::Reader.open(io_string) { |io| io.read }
        end
      end
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
iostreams-0.20.3 test/s3_reader_test.rb
iostreams-0.20.2 test/s3_reader_test.rb
iostreams-0.20.1 test/s3_reader_test.rb
iostreams-0.20.0 test/s3_reader_test.rb
iostreams-0.19.0 test/s3_reader_test.rb
iostreams-0.18.0 test/s3_reader_test.rb
iostreams-0.17.3 test/s3_reader_test.rb
iostreams-0.17.2 test/s3_reader_test.rb
iostreams-0.17.1 test/s3_reader_test.rb
iostreams-0.17.0 test/s3_reader_test.rb