require 'spec_helper' describe MultiSolr::TimelineCoreHandler do init_test_solr subject do MultiSolr::TimelineCoreHandler.new SolrTestdataProvider::SOLR_TEST_INSTANCE_URL, 'core', MultiSolr::SingleCoreHandler end it "should list cores" do subject.list_cores.should == ['core-01', 'core-02'] end it "should get correct last_core_name" do subject.last_core_name.should == 'core-02' end context "create_single_core_handler" do it "should create Handler with last-core-name if no core-name spezified" do handler = subject.create_single_core_handler handler.should be_a(MultiSolr::SingleCoreHandler) handler.core_name.should == subject.last_core_name end it "should create Handler with spezified core-name" do handler = subject.create_single_core_handler 'core-11' handler.core_name.should == 'core-11' end end context "core_status" do it "should without params get the status of all cores" do status = subject.core_status status.keys.should have(2).entries end it "should wit params get the status of the specified core" do status = subject.core_status 'core-01' status['name'].should == 'core-01' end end context "create_core" do before(:all) do @th = subject @new_core_name = @th.create_core SolrTestdataProvider.load_testdata_into_solr @new_core_name end it "should have timestamp aus core-name-suffix" do @th.last_core_name.should =~ /core-#{Time.now.strftime('%Y%m%d')}.*/ end it "should list 3 cores" do @th.list_cores.should have(3).entries end it "should set last_core_name to new core" do @th.last_core_name.should == @new_core_name end it "should correct dataDir" do status = @th.core_status @new_core_name status['dataDir'].should =~ /^\/tmp\/multi-solr\/data\/#{@new_core_name}/ end end context "dataimport" do before(:all) do @result = subject.dataimport 'dataimport-test' end it "should succesfull" do @result.should_not be_nil end it "should status for import" do status_result = subject.dataimport 'dataimport-test', 'status' # Der Datenimport sollte noch laufen status_result['status'].should == 'busy' end end context "remove_core" do before(:all) do @th = subject @th.remove_core 'core-01', true end it "should have not core-01 in core-list" do @th.list_cores.should_not be_include('core-01') end it "should delete DataDir" do File.exist?('/tmp/multi-solr/core-01').should be_false end end end