Sha256: 8a8b035e4bf7b14d544285c1e9011df4219297074282d7db5a47ddd620726440
Contents?: true
Size: 1.36 KB
Versions: 9
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true require 'test_helper' class TestContextShape < Minitest::Test class Email; end def test_field_type_number [ [1, 1], [99999999999999999999999999999999999999999999, 1], [-99999999999999999999999999999999999999999999, 1], ['a', 2], ['99999999999999999999999999999999999999999999', 2], [1.0, 4], [99999999999999999999999999999999999999999999.0, 4], [-99999999999999999999999999999999999999999999.0, 4], [true, 5], [false, 5], [[], 10], [[1, 2, 3], 10], [['a', 'b', 'c'], 10], [Email.new, 2], ].each do |value, expected| actual = Prefab::ContextShape.field_type_number(value) refute_nil actual, "Expected a value for input: #{value}" assert_equal expected, actual, "Expected #{expected} for #{value}" end end # If this test fails, it means that we've added a new type to the ConfigValue def test_mapping_is_exhaustive unsupported = [:bytes, :limit_definition, :log_level, :weighted_values, :int_range] supported = PrefabProto::ConfigValue.descriptor.entries.reject do |entry| unsupported.include?(entry.name.to_sym) end.map(&:number) mapped = Prefab::ContextShape::MAPPING.values.uniq unless mapped == supported raise "ContextShape MAPPING needs update: #{mapped} != #{supported}" end end end
Version data entries
9 entries across 9 versions & 1 rubygems