Sha256: 65a2e8bf8968546793282b700c48e9c8ca9bce8c232315e2bbf10a96f5df80c5

Contents?: true

Size: 1.39 KB

Versions: 26

Compression:

Stored size: 1.39 KB

Contents

require 'test_helper'

module Workarea
  module Configuration
    class RedisTest < TestCase
      def test_find_config
        ENV['WORKAREA_FOO_REDIS_PORT'] = '1234'
        Workarea.config.foo_redis = { scheme: 'rediss' }

        result = Redis.find_config(:foo_redis)
        assert_equal('rediss', result[:scheme])
        assert_equal('1234', result[:port])

      ensure
        ENV.delete('WORKAREA_FOO_REDIS_PORT')
      end

      def test_defaults
        instance = Redis.new(host: 'foo')
        assert_equal('redis', instance.scheme)
        assert_equal('foo', instance.host)
        assert_equal(6379, instance.port)
        assert_equal(0, instance.db)
        refute(instance.ssl?)
        assert_match(URI::regexp, instance.to_url)

        instance = Redis.new(scheme: 'rediss')
        assert_equal('rediss', instance.scheme)
        assert_equal('localhost', instance.host)
        assert_equal(6379, instance.port)
        assert_equal(0, instance.db)
        assert(instance.ssl?)
        assert_match(URI::regexp, instance.to_url)
      end

      def test_to_h
        result = Redis.new(scheme: 'rediss', port: 1234).to_h
        assert_equal('rediss', result[:scheme])
        assert_equal('localhost', result[:host])
        assert_equal(1234, result[:port])
        assert_equal(0, result[:db])
        assert_nil(result[:password])
        assert(result[:ssl])
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.26 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.25 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.23 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.22 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.21 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.20 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.19 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.18 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.17 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.16 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.15 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.14 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.13 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.12 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.11 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.10 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.9 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.8 test/lib/workarea/configuration/redis_test.rb
workarea-core-3.5.7 test/lib/workarea/configuration/redis_test.rb