Sha256: f9685afa7c0bc79168833b416fbd78361a02332292d2d8d9f25559f4789e5c55

Contents?: true

Size: 1.25 KB

Versions: 20

Compression:

Stored size: 1.25 KB

Contents

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

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

  let :api do
    API.new(nil)
  end

  describe 'create_database' do
    it 'should create a new database' do
      stub_api_request(:post, "/v3/database/create/#{e(db_name)}").to_return(:body => {'database' => db_name}.to_json)

      api.create_database(db_name).should be_true
    end

    it 'should return 400 error with invalid name' do
      invalid_name = 'a'
      err_msg = "Name must be 3 to 256 characters, got #{invalid_name.length} characters. name = '#{invalid_name}'"
      stub_api_request(:post, "/v3/database/create/#{e(invalid_name)}").to_return(:status => 400, :body => {'message' => err_msg}.to_json)

      expect {
        api.create_database(invalid_name)
      }.to raise_error(TreasureData::APIError, /^#{err_msg}/)
    end

    it 'should return 409 error with duplicated name' do
      err_msg = "Database #{db_name} already exists"
      stub_api_request(:post, "/v3/database/create/#{e(db_name)}").to_return(:status => 409, :body => {'message' => err_msg}.to_json)

      expect {
        api.create_database(db_name)
      }.to raise_error(TreasureData::APIError, /^#{err_msg}/)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

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