Sha256: 192a436914d1128977b7c34a3feb48e8d75ee13b444e7beb67331f9f5b350266

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

require 'test_helper'

module Elasticsearch
  module Test
    class IndicesPutMappingTest < ::Test::Unit::TestCase

      context "Indices: Put mapping" do
        subject { FakeClient.new }

        should "require the :index argument" do
          assert_raise ArgumentError do
            subject.indices.put_mapping :type => 'bar'
          end
        end

        should "require the :type argument" do
          assert_raise ArgumentError do
            subject.indices.put_mapping :index => 'foo'
          end
        end

        should "perform correct request" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'PUT', method
            assert_equal 'foo/bar/_mapping', url
            assert_equal Hash.new, params
            assert_equal({ :foo => {} }, body)
            true
          end.returns(FakeResponse.new)

          subject.indices.put_mapping :index => 'foo', :type => 'bar', :body => { :foo => {} }
        end

        should "perform request against multiple indices" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'foo,bar/bam/_mapping', url
            true
          end.returns(FakeResponse.new)

          subject.indices.put_mapping :index => ['foo','bar'], :type => 'bam', :body => {}
        end

        should "pass the URL parameters" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'foo/bar/_mapping', url
            assert_equal true, params[:ignore_conflicts]
            true
          end.returns(FakeResponse.new)

          subject.indices.put_mapping :index => 'foo', :type => 'bar', :body => {}, :ignore_conflicts => true
        end

      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elasticsearch-api-0.4.0 test/unit/indices/put_mapping_test.rb
elasticsearch-api-0.0.2 test/unit/indices/put_mapping_test.rb