Sha256: 83527cc78f6a3ae8f301ec4ebac5a8d59e69972c5aaf19a815335dc2e0728fbe

Contents?: true

Size: 1.71 KB

Versions: 49

Compression:

Stored size: 1.71 KB

Contents

# encoding: utf-8
require "logstash/modules/logstash_config"

describe LogStash::Modules::LogStashConfig do
  let(:mod) { instance_double("Modules", :directory => Stud::Temporary.directory, :module_name => "testing") }
  let(:settings) { {"var.logstash.testing.pants" => "fancy" }}
  subject { described_class.new(mod, settings) }

  describe "configured inputs" do
    context "when no inputs is send" do
      it "returns the default" do
        expect(subject.configured_inputs(["kafka"])).to include("kafka")
      end
    end

    context "when inputs are send" do
      let(:settings) { { "var.inputs" => "tcp" } }

      it "returns the configured inputs" do
        expect(subject.configured_inputs(["kafka"])).to include("tcp")
      end

      context "when alias is specified" do
        let(:settings) { { "var.inputs" => "smartconnector" } }

        it "returns the configured inputs" do
          expect(subject.configured_inputs(["kafka"], { "smartconnector" => "tcp"  })).to include("tcp", "smartconnector")
        end
      end
    end
  end

  describe "array to logstash array string" do
    it "return an escaped string" do
      expect(subject.array_to_string(["hello", "ninja"])).to eq("['hello', 'ninja']")
    end
  end

  describe "alias modules options" do
    let(:alias_table) do
      { "var.logstash.testing" => "var.logstash.better" }
    end

    before do
      subject.alias_settings_keys!(alias_table)
    end

    it "allow to retrieve settings" do
      expect(subject.setting("var.logstash.better.pants", "dont-exist")).to eq("fancy")
    end

    it "allow to retrieve settings with the original name" do
      expect(subject.setting("var.logstash.testing.pants", "dont-exist")).to eq("fancy")
    end
  end
end

Version data entries

49 entries across 49 versions & 5 rubygems

Version Path
logstash-core-5.6.8-java spec/logstash/modules/logstash_config_spec.rb
logstash-core-5.6.7-java spec/logstash/modules/logstash_config_spec.rb
logstash-core-5.6.6-java spec/logstash/modules/logstash_config_spec.rb
logstash-core-5.6.5-java spec/logstash/modules/logstash_config_spec.rb
logstash-core-5.6.4-java spec/logstash/modules/logstash_config_spec.rb
logstash-core-5.6.3-java spec/logstash/modules/logstash_config_spec.rb
logstash-core-5.6.2-java spec/logstash/modules/logstash_config_spec.rb
logstash-core-5.6.1-java spec/logstash/modules/logstash_config_spec.rb
logstash-core-5.6.0-java spec/logstash/modules/logstash_config_spec.rb