From cb4c7cfb8c098fd94a83ef6e6a5ec3ecb87c9408 Mon Sep 17 00:00:00 2001 From: Ruslan Korolev Date: Mon, 17 Aug 2015 16:51:01 +0300 Subject: [PATCH] add headers + length test for upload io --- spec/google/apis/core/upload_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/google/apis/core/upload_spec.rb b/spec/google/apis/core/upload_spec.rb index 379f14cf4..b6265a8c3 100644 --- a/spec/google/apis/core/upload_spec.rb +++ b/spec/google/apis/core/upload_spec.rb @@ -47,6 +47,12 @@ RSpec.describe Google::Apis::Core::UploadIO do io = Google::Apis::Core::UploadIO.from_file(file, content_type: 'application/json') expect(io.content_type).to eql('application/json') end + + it 'should setup length of the stream' do + upload_io = Google::Apis::Core::UploadIO.from_file(file) + expect(upload_io.length).to eq File.size(file) + end + end end @@ -64,6 +70,11 @@ RSpec.describe Google::Apis::Core::UploadIO do upload_io = Google::Apis::Core::UploadIO.from_io(io, content_type: 'application/x-gzip') expect(upload_io.content_type).to eq('application/x-gzip') end + + it 'should setup length of the stream' do + upload_io = Google::Apis::Core::UploadIO.from_io(io) + expect(upload_io.length).to eq 'Hello google'.length + end end end @@ -96,6 +107,12 @@ RSpec.describe Google::Apis::Core::RawUploadCommand do expect(a_request(:post, 'https://www.googleapis.com/zoo/animals') .with { |req| req.headers['X-Goog-Upload-Protocol'] == 'raw' }).to have_been_made end + + it 'should send content-type header' do + command.execute(client) + expect(a_request(:post, 'https://www.googleapis.com/zoo/animals') + .with { |req| req.headers['X-Goog-Upload-Header-Content-Type'] == 'text/plain' }).to have_been_made + end end context('with StringIO input') do