Sha256: b82042977a83c185680f12edcfe0371310ab9d5507d65e357251c48dd7272edb

Contents?: true

Size: 1.69 KB

Versions: 4

Compression:

Stored size: 1.69 KB

Contents

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

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

  let :api do
    API.new(nil)
  end

  describe 'partialdelete' do
    let :from do
      0
    end

    let :to do
      3600 * 10
    end

    let :from_to do
      {'from' => from.to_s, 'to' => to.to_s}
    end

    it 'should partial_delete successfully' do
      # TODO: Use correnty values
      stub_api_request(:post, "/v3/table/partialdelete/#{e(db_name)}/#{e(table_name)}").with(:body => from_to)
        .to_return(:body => {'database' => db_name, 'table' => table_name, 'job_id' => '1'}.to_json)

      api.partial_delete(db_name, table_name, to, from).should == '1'
    end

    it 'should return 404 error with non exist database name' do
      db = 'no_such_db'
      err_msg = "Couldn't find UserDatabase with name = #{db}"
      stub_api_request(:post, "/v3/table/partialdelete/#{e(db)}/#{e(table_name)}").with(:body => from_to)
        .to_return(:status => 404, :body => {'message' => err_msg}.to_json)

      expect {
        api.partial_delete(db, table_name, to, from)
      }.to raise_error(TreasureData::APIError, /#{err_msg}/)
    end

    it 'should return 404 error with non exist table name' do
      table = 'no_such_table'
      err_msg = "Unknown table: #{table}"
      stub_api_request(:post, "/v3/table/partialdelete/#{e(db_name)}/#{e(table)}").with(:body => from_to)
        .to_return(:status => 404, :body => {'message' => err_msg}.to_json)

      expect {
        api.partial_delete(db_name, table, to, from)
      }.to raise_error(TreasureData::APIError, /#{err_msg}/)
    end

    # TODO: Add from / to parameters spec
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
td-client-0.8.66 spec/td/client/partial_delete_api_spec.rb
td-client-0.8.65 spec/td/client/partial_delete_api_spec.rb
td-client-0.8.64 spec/td/client/partial_delete_api_spec.rb
td-client-0.8.63 spec/td/client/partial_delete_api_spec.rb