Sha256: f3eb23dfae1ebca2a0a9c2371e209f2f98a23b2c05ab6659823c0453a6be434e

Contents?: true

Size: 1.94 KB

Versions: 77

Compression:

Stored size: 1.94 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 :type argument" do
          assert_raise ArgumentError do
            subject.indices.put_mapping :index => 'foo', :body => {}
          end
        end

        should "perform correct request" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'PUT', method
            assert_equal 'foo/_mapping/bar', 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/_mapping/bam', 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/_mapping/bar', 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

        should "URL-escape the parts" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'foo%5Ebar/_mapping/bar%2Fbam', url
            true
          end.returns(FakeResponse.new)

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

      end

    end
  end
end

Version data entries

77 entries across 77 versions & 6 rubygems

Version Path
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/elasticsearch-api-5.0.4/test/unit/indices/put_mapping_test.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/elasticsearch-api-5.0.4/test/unit/indices/put_mapping_test.rb
elasticsearch-api-5.0.4 test/unit/indices/put_mapping_test.rb
elasticsearch-api-2.0.2 test/unit/indices/put_mapping_test.rb
elasticsearch-api-5.0.3 test/unit/indices/put_mapping_test.rb
elasticsearch-api-5.0.2 test/unit/indices/put_mapping_test.rb
elasticsearch-api-5.0.1 test/unit/indices/put_mapping_test.rb
elasticsearch-api-2.0.1 test/unit/indices/put_mapping_test.rb
elasticsearch-api-1.1.2 test/unit/indices/put_mapping_test.rb
elasticsearch-api-1.1.1 test/unit/indices/put_mapping_test.rb
elasticsearch-api-5.0.0 test/unit/indices/put_mapping_test.rb
elasticsearch-api-5.0.0.pre test/unit/indices/put_mapping_test.rb
elasticsearch-api-2.0.0 test/unit/indices/put_mapping_test.rb
elasticsearch-api-1.1.0 test/unit/indices/put_mapping_test.rb
elasticsearch-api-2.0.0.pre test/unit/indices/put_mapping_test.rb
elasticsearch-api-1.1.pre test/unit/indices/put_mapping_test.rb
elasticsearch-api-1.0.18 test/unit/indices/put_mapping_test.rb
elasticsearch-api-1.0.17 test/unit/indices/put_mapping_test.rb
elasticsearch-api-1.0.16 test/unit/indices/put_mapping_test.rb
elasticsearch-api-1.0.16.pre2 test/unit/indices/put_mapping_test.rb