Sha256: c645bde569de1b906a98f3224ae08bd24b89d137959277138fd3e9e8f10a970a

Contents?: true

Size: 1.31 KB

Versions: 20

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

20 entries across 20 versions & 1 rubygems

Version Path
td-client-0.8.62 spec/td/client/export_api_spec.rb
td-client-0.8.61 spec/td/client/export_api_spec.rb
td-client-0.8.60 spec/td/client/export_api_spec.rb
td-client-0.8.59 spec/td/client/export_api_spec.rb
td-client-0.8.58 spec/td/client/export_api_spec.rb
td-client-0.8.57 spec/td/client/export_api_spec.rb
td-client-0.8.56 spec/td/client/export_api_spec.rb
td-client-0.8.55 spec/td/client/export_api_spec.rb
td-client-0.8.54 spec/td/client/export_api_spec.rb
td-client-0.8.53 spec/td/client/export_api_spec.rb
td-client-0.8.52 spec/td/client/export_api_spec.rb
td-client-0.8.51 spec/td/client/export_api_spec.rb
td-client-0.8.50 spec/td/client/export_api_spec.rb
td-client-0.8.49 spec/td/client/export_api_spec.rb
td-client-0.8.48 spec/td/client/export_api_spec.rb
td-client-0.8.47 spec/td/client/export_api_spec.rb
td-client-0.8.46 spec/td/client/export_api_spec.rb
td-client-0.8.45 spec/td/client/export_api_spec.rb
td-client-0.8.44 spec/td/client/export_api_spec.rb
td-client-0.8.43 spec/td/client/export_api_spec.rb