Sha256: 835cc9f81af0e008fa09d345f95e3ae5370062a46c2d43d57428ee1149249d03

Contents?: true

Size: 1.95 KB

Versions: 35

Compression:

Stored size: 1.95 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe LogStash::Agent do
  subject { LogStash::Agent.new('') }
  let(:dummy_config) { 'input {}' }

  context "when loading the configuration" do
    context "when local" do
      before { expect(subject).to receive(:local_config).with(path) }

      context "unix" do
        let(:path) { './test.conf' }
        it 'works with relative path' do
          subject.load_config(path)
        end
      end

      context "windows" do
        let(:path) { '.\test.conf' }
        it 'work with relative windows path' do
          subject.load_config(path)
        end
      end
    end

    context "when remote" do
      context 'supported scheme' do
        let(:path) { "http://test.local/superconfig.conf" }

        before { expect(Net::HTTP).to receive(:get) { dummy_config } }
        it 'works with http' do
          expect(subject.load_config(path)).to eq("#{dummy_config}\n")
        end
      end
    end
  end

  context "--pluginpath" do
    let(:single_path) { "/some/path" }
    let(:multiple_paths) { ["/some/path1", "/some/path2"] }

    it "should add single valid dir path to the environment" do
      expect(File).to receive(:directory?).and_return(true)
      expect(LogStash::Environment).to receive(:add_plugin_path).with(single_path)
      subject.configure_plugin_paths(single_path)
    end

    it "should fail with single invalid dir path" do
      expect(File).to receive(:directory?).and_return(false)
      expect(LogStash::Environment).not_to receive(:add_plugin_path)
      expect{subject.configure_plugin_paths(single_path)}.to raise_error(LogStash::ConfigurationError)
    end

    it "should add multiple valid dir path to the environment" do
      expect(File).to receive(:directory?).exactly(multiple_paths.size).times.and_return(true)
      multiple_paths.each{|path| expect(LogStash::Environment).to receive(:add_plugin_path).with(path)}
      subject.configure_plugin_paths(multiple_paths)
    end
  end
end

Version data entries

35 entries across 32 versions & 3 rubygems

Version Path
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/logstash-core-1.5.4-java/spec/logstash/agent_spec.rb
logstash-core-2.2.3-java spec/logstash/agent_spec.rb
logstash-core-2.2.3.snapshot2-java spec/logstash/agent_spec.rb
logstash-core-2.2.2-java spec/logstash/agent_spec.rb
logstash-core-2.1.3-java spec/logstash/agent_spec.rb
logstash-core-2.2.1-java spec/logstash/agent_spec.rb
logstash-core-2.2.1.snapshot1-java spec/logstash/agent_spec.rb
logstash-core-2.1.2-java spec/logstash/agent_spec.rb
logstash-core-2.2.0-java spec/logstash/agent_spec.rb
logstash-core-2.1.2.snapshot1-java spec/logstash/agent_spec.rb
logstash-core-2.2.0.snapshot3-java spec/logstash/agent_spec.rb
logstash-core-2.2.0.snapshot2-java spec/logstash/agent_spec.rb
logstash-core-2.1.1-java spec/logstash/agent_spec.rb
logstash-core-1.5.6-java spec/logstash/agent_spec.rb
logstash-core-2.1.0-java spec/logstash/agent_spec.rb
logstash-core-2.1.0.snapshot4-java spec/logstash/agent_spec.rb
logstash-core-2.1.0.snapshot3-java spec/logstash/agent_spec.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-core-2.0.0-java/spec/logstash/agent_spec.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-core-2.0.1-java/spec/logstash/agent_spec.rb
logstash-core-2.0.1-java spec/logstash/agent_spec.rb