Sha256: 6d4bab38c4ad4987a039a460b0f01a50ecf1145640c362125e8c301f422559d9

Contents?: true

Size: 1.31 KB

Versions: 15

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'
require 'td/client/spec_resources'

describe 'Export API' do
  include_context 'spec symbols'
  include_context 'common helper'

  let :api do
    API.new(nil)
  end

  describe 'export' do
    let :storage_type do
      's3'
    end

    it 'should export successfully' do
      # TODO: Use correnty values
      params = {'file_format' => 'json.gz', 'bucket' => 'bin', 'access_key_id' => 'id', 'secret_access_key' => 'secret'}
      stub_api_request(:post, "/v3/export/run/#{e(db_name)}/#{e(table_name)}").with(:body => params.merge('storage_type' => storage_type)).
        to_return(:body => {'database' => db_name, 'job_id' => '1', 'debug' => {}}.to_json)

      api.export(db_name, table_name, storage_type, params).should == '1'
    end

    it 'should return 400 error with invalid storage type' do
      invalid_type = 'gridfs'
      params = {'storage_type' => invalid_type}
      err_msg = "Only s3 output type is supported: #{invalid_type}"
      stub_api_request(:post, "/v3/export/run/#{e(db_name)}/#{e(table_name)}").with(:body => params).
        to_return(:status => 400, :body => {'message' => err_msg}.to_json)

      expect {
        api.export(db_name, table_name, invalid_type)
      }.to raise_error(TreasureData::APIError, /#{err_msg}/)
    end

    # TODO: Add other parameters spec
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
td-client-0.8.79 spec/td/client/export_api_spec.rb
td-client-0.8.78 spec/td/client/export_api_spec.rb
td-client-0.9.0dev2 spec/td/client/export_api_spec.rb
td-client-0.9.0dev1 spec/td/client/export_api_spec.rb
td-client-0.8.77 spec/td/client/export_api_spec.rb
td-client-0.8.76 spec/td/client/export_api_spec.rb
td-client-0.8.75 spec/td/client/export_api_spec.rb
td-client-0.8.74 spec/td/client/export_api_spec.rb
td-client-0.8.73 spec/td/client/export_api_spec.rb
td-client-0.8.72 spec/td/client/export_api_spec.rb
td-client-0.8.71 spec/td/client/export_api_spec.rb
td-client-0.8.70 spec/td/client/export_api_spec.rb
td-client-0.8.69 spec/td/client/export_api_spec.rb
td-client-0.8.68 spec/td/client/export_api_spec.rb
td-client-0.8.67 spec/td/client/export_api_spec.rb