Sha256: fc4215489d8bea9818ded5997499feb4885afac3cea08c408caa8ba5163e19f7
Contents?: true
Size: 1.43 KB
Versions: 17
Compression:
Stored size: 1.43 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, :provided] type_fields = PrefabProto::ConfigValue.descriptor.lookup_oneof("type").entries supported = type_fields.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
17 entries across 17 versions & 1 rubygems