Sha256: bbce3c6781ed6c1eeb41420dd54923cb54d2f12e7dd8d7f637184453dbad1fb1

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

require 'test_helper'

class TestOptions < Minitest::Test
  API_KEY = 'abcdefg'

  def test_prefab_api_url
    assert_equal 'https://api.prefab.cloud', Prefab::Options.new.prefab_api_url

    with_env 'PREFAB_API_URL', 'https://api.prefab.cloud' do
      assert_equal 'https://api.prefab.cloud', Prefab::Options.new.prefab_api_url
    end

    with_env 'PREFAB_API_URL', 'https://api.prefab.cloud/' do
      assert_equal 'https://api.prefab.cloud', Prefab::Options.new.prefab_api_url
    end
  end

  def test_works_with_named_arguments
    assert_equal API_KEY, Prefab::Options.new(api_key: API_KEY).api_key
  end

  def test_works_with_hash
    assert_equal API_KEY, Prefab::Options.new({ api_key: API_KEY }).api_key
  end

  def test_collect_max_paths
    assert_equal 1000, Prefab::Options.new.collect_max_paths
    assert_equal 100, Prefab::Options.new(collect_max_paths: 100).collect_max_paths
  end

  def test_collect_max_paths_with_local_only
    options = Prefab::Options.new(collect_max_paths: 100,
                                  prefab_datasources: Prefab::Options::DATASOURCES::LOCAL_ONLY)
    assert_equal 0, options.collect_max_paths
  end

  def test_collect_max_paths_with_collect_logs_false
    options = Prefab::Options.new(collect_max_paths: 100,
                                  collect_logs: false)
    assert_equal 0, options.collect_max_paths
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
prefab-cloud-ruby-0.24.5 test/test_options.rb
prefab-cloud-ruby-0.24.4 test/test_options.rb
prefab-cloud-ruby-0.24.3 test/test_options.rb
prefab-cloud-ruby-0.24.2 test/test_options.rb
prefab-cloud-ruby-0.24.1 test/test_options.rb
prefab-cloud-ruby-0.24.0 test/test_options.rb
prefab-cloud-ruby-0.23.8 test/test_options.rb
prefab-cloud-ruby-0.23.7 test/test_options.rb
prefab-cloud-ruby-0.23.6 test/test_options.rb
prefab-cloud-ruby-0.23.5 test/test_options.rb
prefab-cloud-ruby-0.23.4 test/test_options.rb
prefab-cloud-ruby-0.23.3 test/test_options.rb
prefab-cloud-ruby-0.23.2 test/test_options.rb