Sha256: 652ca5e7d94bca97431f4fd78fce8c0e41ad804a20262a3439d0cfc9b3fc0e99

Contents?: true

Size: 1.67 KB

Versions: 12

Compression:

Stored size: 1.67 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)

      expect(api.export(db_name, table_name, storage_type, params)).to eq('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

  describe 'result_export' do
    it 'should export result successfully' do
      params = {'result' => 'mysql://user:pass@host.com/database/table'}
      stub_api_request(:post, "/v3/job/result_export/100").with(:body => params).
        to_return(:body => {'job_id' => '101'}.to_json)

      expect(api.result_export(100, params)).to eq('101')
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
td-client-2.0.0 spec/td/client/export_api_spec.rb
td-client-1.0.8 spec/td/client/export_api_spec.rb
td-client-1.0.7 spec/td/client/export_api_spec.rb
td-client-1.0.6 spec/td/client/export_api_spec.rb
td-client-1.0.5 spec/td/client/export_api_spec.rb
td-client-1.0.4 spec/td/client/export_api_spec.rb
td-client-1.0.3 spec/td/client/export_api_spec.rb
td-client-1.0.2 spec/td/client/export_api_spec.rb
td-client-1.0.1 spec/td/client/export_api_spec.rb
td-client-1.0.0-java spec/td/client/export_api_spec.rb
td-client-1.0.0 spec/td/client/export_api_spec.rb
td-client-0.8.85 spec/td/client/export_api_spec.rb