Sha256: c7728451a500b0a93681abc078da081b9857a86fad71708252debf84133d025a

Contents?: true

Size: 1012 Bytes

Versions: 10

Compression:

Stored size: 1012 Bytes

Contents

require_relative 'test_helper'

class FileWriterTest < Minitest::Test
  describe IOStreams::File::Writer 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 'writes' do
        unless ENV['S3_BUCKET_NAME']
          skip "Supply 'S3_BUCKET_NAME' environment variable with S3 bucket name to test with"
        end

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

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

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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