Sha256: 591cf9c276c6f124cb9f0400a94f2ebd2439f55e21655f52a4ede9a378a9667b

Contents?: true

Size: 1.53 KB

Versions: 7

Compression:

Stored size: 1.53 KB

Contents

require_relative '../test_helper'

# Unit Test for SemanticLogger::Appender::Splunk
#
module Appender
  class SplunkTest < Minitest::Test
    describe SemanticLogger::Appender::Splunk do

      describe '#parse_options' do
        describe 'argument errors' do
          it 'raise argument error for missing username' do
            error = assert_raises ArgumentError do
              SemanticLogger::Appender::Splunk.new({})
            end

            assert_equal 'Must supply a username.', error.message
          end

          it 'raise argument error for missing password' do
            error = assert_raises ArgumentError do
              SemanticLogger::Appender::Splunk.new(username: 'username')
            end

            assert_equal 'Must supply a password.', error.message
          end
        end

        describe 'set default values' do
          it 'have default values' do
            appender = Splunk.stub(:connect, Splunk::Service.new({})) do
              Splunk::Service.stub_any_instance(:indexes, {}) do
                SemanticLogger::Appender::Splunk.new(username: 'username', password: 'password')
              end
            end
            config   = appender.config
            # Default host
            assert_equal 'localhost', config[:host]
            # Default port
            assert_equal 8089, config[:port]
            # Default scheme
            assert_equal :https, config[:scheme]
            #Default index
            assert_equal 'main', appender.index
          end
        end
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
semantic_logger-3.1.0 test/appender/splunk_test.rb
semantic_logger-3.0.1 test/appender/splunk_test.rb
semantic_logger-3.0.0 test/appender/splunk_test.rb
semantic_logger-2.21.0 test/appender/splunk_test.rb
semantic_logger-2.20.0 test/appender/splunk_test.rb
semantic_logger-2.19.0 test/appender/splunk_test.rb
semantic_logger-2.18.0 test/appender/splunk_test.rb