Sha256: 658eee513d4c050c5feeec2afe0f68bbdec37230344da9a139774fd5934a4dbd

Contents?: true

Size: 1.62 KB

Versions: 24

Compression:

Stored size: 1.62 KB

Contents

require 'test_helper'

class TestConfigResolver < Minitest::Test

  def test_resolution
    @loader = MockConfigLoader.new

    loaded_values = {
      "projectA:key" => Prefab::ConfigValue.new(string: "valueA"),
      "key" => Prefab::ConfigValue.new(string: "value_none"),
      "projectB:key" => Prefab::ConfigValue.new(string: "valueB"),
      "projectB.subprojectX:key" => Prefab::ConfigValue.new(string: "projectB.subprojectX"),
      "projectB.subprojectY:key" => Prefab::ConfigValue.new(string: "projectB.subprojectY"),
      "projectB:key2" => Prefab::ConfigValue.new(string: "valueB2")
    }

    @loader.stub :calc_config, loaded_values do
      @resolver = Prefab::ConfigResolver.new(MockBaseClient.new, @loader)
      assert_equal "value_none", @resolver.get("key")


      @resolverA = resolver_for_namespace("projectA", @loader)
      assert_equal "valueA", @resolverA.get("key")

      @resolverB = resolver_for_namespace("projectB", @loader)
      assert_equal "valueB", @resolverB.get("key")

      @resolverBX = resolver_for_namespace("projectB.subprojectX", @loader)
      assert_equal "projectB.subprojectX", @resolverBX.get("key")

      @resolverUndefinedSubProject = resolver_for_namespace("projectB.subprojectX:subsubQ", @loader)
      assert_equal "projectB.subprojectX", @resolverBX.get("key")

      @resolverBX = resolver_for_namespace("projectC", @loader)
      assert_equal "value_none", @resolverBX.get("key")
      assert_nil @resolverBX.get("key_that_doesnt_exist")
    end
  end

  def resolver_for_namespace(namespace, loader)
    Prefab::ConfigResolver.new(MockBaseClient.new(namespace: namespace), loader)
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
prefab-cloud-ruby-0.3.0 test/test_config_resolver.rb
prefab-cloud-ruby-0.2.0 test/test_config_resolver.rb
prefab-cloud-ruby-0.1.1 test/test_config_resolver.rb
prefab-cloud-ruby-0.1.0 test/test_config_resolver.rb
prefab-cloud-ruby-0.1.0.alpha.1 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.28 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.27 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.26 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.25 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.24 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.23 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.22 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.21 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.20 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.19 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.18 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.17 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.16 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.15 test/test_config_resolver.rb
prefab-cloud-ruby-0.0.14 test/test_config_resolver.rb