Sha256: be59892ffabe21800e0a260c2aff1b64ce15fb42f86cb5d2abe2bead89fe7c1c

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
require "logstash/filters/geoip"
require_relative 'test_helper'

describe LogStash::Filters::GeoIP do

  describe "database path", :aggregate_failures do
    let(:plugin) { LogStash::Filters::GeoIP.new("source" => "[target][ip]", "database" => DEFAULT_ASN_DB_PATH) }

    before :each do
      logstash_path = ENV['LOGSTASH_PATH'] || '/usr/share/logstash' # docker logstash home
      stub_const('LogStash::Environment::LOGSTASH_HOME', logstash_path)
    end

    context "select_database_path with static path" do
      it "should be the assigned path" do
        expect(plugin.select_database_path).to eql(DEFAULT_ASN_DB_PATH)
      end
    end

    shared_examples "with database manager" do
      it "load_database_manager? should be true" do
        expect(plugin.load_database_manager?).to be_truthy
      end
    end

    shared_examples "without database manager" do
      it "load_database_manager? should be false" do
        expect(plugin.load_database_manager?).to be_falsey
      end

      describe "select_database_path without path setting" do
        let(:plugin) { LogStash::Filters::GeoIP.new("source" => "[target][ip]") }

        it "should be default" do
          expect(plugin.select_database_path).to eql(DEFAULT_CITY_DB_PATH)
        end
      end
    end

    if MAJOR >= 8 || (MAJOR == 7 && MINOR >= 14)
      context "Logstash >= 7.14" do
        if LogStash::OSS
          context "OSS-only" do
            include_examples "without database manager"
          end
        else
          context "default distro" do
            include_examples "with database manager"
          end
        end
      end
    else
      describe "Logstash < 7.14" do
        include_examples "without database manager"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-filter-geoip-7.3.1-java spec/filters/geoip_spec.rb