Sha256: b1d01e010ca71ebea2a0ccdb44ab2f780589b03eabf29c609e6c45fff6b20186

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

require 'test_helper'

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

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

        should "require the :index argument" do
          assert_raise ArgumentError do
            subject.indices.put_warmer :name => 'foo', :body => {}
          end
        end

        should "require the :name argument" do
          assert_raise ArgumentError do
            subject.indices.put_warmer :index => 'foo', :body => {}
          end
        end

        should "require the :body argument" do
          assert_raise ArgumentError do
            subject.indices.put_warmer :index => 'foo', :name => 'bar'
          end
        end

        should "perform correct request" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'PUT', method
            assert_equal 'foo/_warmer/bar', url
            assert_equal Hash.new, params
            assert_equal :match_all, body[:query].keys.first
            true
          end.returns(FakeResponse.new)

          subject.indices.put_warmer :index => 'foo', :name => 'bar', :body => { :query => { :match_all => {} } }
        end

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

          subject.indices.put_warmer :index => ['foo','bar'], :name => 'xul', :body => {}
        end

        should "perform request against an index and type" do
          subject.expects(:perform_request).with do |method, url, params, body|
            assert_equal 'foo/bar/_warmer/xul', url
            true
          end.returns(FakeResponse.new)

          subject.indices.put_warmer :index => 'foo', :type => 'bar', :name => 'xul', :body => {}
        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_warmer_test.rb
elasticsearch-api-0.0.2 test/unit/indices/put_warmer_test.rb