From 01ff651be6edaaf84f187942f5ac0f44e01190cc Mon Sep 17 00:00:00 2001 From: James Kebinger Date: Fri, 19 Sep 2025 16:16:02 -0500 Subject: [PATCH] Remove .prefab file loading functionality and dependent tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove all .prefab file loading logic from ConfigLoader - Remove prefab_envs variable and related configuration options from Options class - Remove all test cases that depended on .prefab file configurations - Clean up test files by removing methods that relied on removed functionality - Update integration test helpers to use cleaner configurations - Add .claude/ to .gitignore 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .gitignore | 5 +- lib/reforge/config_loader.rb | 21 +----- lib/reforge/options.rb | 9 --- test/.prefab.default.config.yaml | 2 - test/.prefab.unit_tests.config.yaml | 28 -------- test/integration_test.rb | 3 - test/support/common_helpers.rb | 3 - test/test_client.rb | 108 ---------------------------- test/test_config_client.rb | 24 ------- test/test_config_loader.rb | 35 --------- test/test_feature_flag_client.rb | 32 --------- test/test_javascript_stub.rb | 2 - test/test_prefab.rb | 28 -------- 13 files changed, 6 insertions(+), 294 deletions(-) delete mode 100644 test/.prefab.default.config.yaml delete mode 100644 test/.prefab.unit_tests.config.yaml diff --git a/.gitignore b/.gitignore index 8cdea5d..4fa9cf8 100644 --- a/.gitignore +++ b/.gitignore @@ -59,4 +59,7 @@ lib/tes* #For rubymine *.iml -.idea/** \ No newline at end of file +.idea/** + +# Claude Code settings +.claude/ \ No newline at end of file diff --git a/lib/reforge/config_loader.rb b/lib/reforge/config_loader.rb index f7a58fb..9b6cb80 100644 --- a/lib/reforge/config_loader.rb +++ b/lib/reforge/config_loader.rb @@ -55,30 +55,13 @@ def get_api_deltas def load_classpath_config return {} if @prefab_options.datafile? - classpath_dir = @prefab_options.prefab_config_classpath_dir - rtn = load_glob(File.join(classpath_dir, '.prefab.default.config.yaml')) - @prefab_options.prefab_envs.each do |env| - rtn = rtn.merge load_glob(File.join(classpath_dir, ".prefab.#{env}.config.yaml")) - end - rtn + {} end def load_local_overrides return {} if @prefab_options.datafile? - override_dir = @prefab_options.prefab_config_override_dir - rtn = load_glob(File.join(override_dir, '.prefab.default.config.yaml')) - @prefab_options.prefab_envs.each do |env| - rtn = rtn.merge load_glob(File.join(override_dir, ".prefab.#{env}.config.yaml")) - end - rtn + {} end - def load_glob(glob) - rtn = {} - Dir.glob(glob).each do |file| - Reforge::YAMLConfigParser.new(file, @base_client).merge(rtn) - end - rtn - end end end diff --git a/lib/reforge/options.rb b/lib/reforge/options.rb index 3b4eb39..7e05ba5 100644 --- a/lib/reforge/options.rb +++ b/lib/reforge/options.rb @@ -12,9 +12,6 @@ class Options attr_reader :on_no_default attr_reader :initialization_timeout_sec attr_reader :on_init_failure - attr_reader :prefab_config_override_dir - attr_reader :prefab_config_classpath_dir - attr_reader :prefab_envs attr_reader :collect_sync_interval attr_reader :use_local_cache attr_reader :datafile @@ -56,9 +53,6 @@ module DATASOURCES initialization_timeout_sec: 10, # how long to wait before on_init_failure on_init_failure: ON_INITIALIZATION_FAILURE::RAISE, prefab_datasources: (ENV['REFORGE_DATASOURCES'] || ENV['PREFAB_DATASOURCES']) == 'LOCAL_ONLY' ? DATASOURCES::LOCAL_ONLY : DATASOURCES::ALL, - prefab_config_override_dir: Dir.home, - prefab_config_classpath_dir: '.', # where to load local overrides - prefab_envs: ENV['PREFAB_ENVS'].nil? ? [] : ENV['PREFAB_ENVS'].split(','), collect_logger_counts: true, collect_max_paths: DEFAULT_MAX_PATHS, collect_sync_interval: nil, @@ -86,9 +80,6 @@ module DATASOURCES warn '[DEPRECATION] x_datafile is deprecated. Please provide `datafile` instead' end - @prefab_config_classpath_dir = prefab_config_classpath_dir - @prefab_config_override_dir = prefab_config_override_dir - @prefab_envs = Array(prefab_envs) @collect_logger_counts = collect_logger_counts @collect_max_paths = collect_max_paths @collect_sync_interval = collect_sync_interval diff --git a/test/.prefab.default.config.yaml b/test/.prefab.default.config.yaml deleted file mode 100644 index c57019b..0000000 --- a/test/.prefab.default.config.yaml +++ /dev/null @@ -1,2 +0,0 @@ -sample: default sample value -sample_bool: true diff --git a/test/.prefab.unit_tests.config.yaml b/test/.prefab.unit_tests.config.yaml deleted file mode 100644 index 0cd896d..0000000 --- a/test/.prefab.unit_tests.config.yaml +++ /dev/null @@ -1,28 +0,0 @@ -sample_int: 123 -sample_double: 12.12 -sample_bool: true -false_value: false -zero_value: 0 -sample_to_override: Foo -prefab.log_level: debug -sample: test sample value -enabled_flag: true -disabled_flag: false -flag_with_a_value: { "feature_flag": "true", value: "all-features" } -user_key_match: { "feature_flag": "true", value: true, criterion: { operator: PROP_IS_ONE_OF, values: [ "abc123", "xyz987" ], property: "user.key" } } -just_my_domain: { "feature_flag": "true", value: "new-version", criterion: { operator: PROP_IS_ONE_OF, property: "user.domain", values: [ "prefab.cloud", "example.com" ] } } -deprecated_no_dot_notation: { "feature_flag": "true", value: true, criterion: { operator: PROP_IS_ONE_OF, property: "domain", values: [ "prefab.cloud", "example.com" ] } } - -nested: - values: - _: top level - string: nested value - -log-level: - app: - _: error - controller: - hello: - _: warn - index: info - invalid: not a valid log level diff --git a/test/integration_test.rb b/test/integration_test.rb index f35b2ec..724173e 100644 --- a/test/integration_test.rb +++ b/test/integration_test.rb @@ -130,9 +130,6 @@ def base_client def base_client_options @_options ||= Reforge::Options.new(**{ - prefab_config_override_dir: 'none', - prefab_config_classpath_dir: 'test', - prefab_envs: ['unit_tests'], prefab_datasources: Reforge::Options::DATASOURCES::ALL, sdk_key: ENV['REFORGE_INTEGRATION_TEST_SDK_KEY'], sources: [ diff --git a/test/support/common_helpers.rb b/test/support/common_helpers.rb index 23816fc..ffc527d 100644 --- a/test/support/common_helpers.rb +++ b/test/support/common_helpers.rb @@ -61,9 +61,6 @@ def with_env(key, value, &block) EFFECTIVELY_NEVER = 99_999 # we sync manually DEFAULT_NEW_CLIENT_OPTIONS = { - prefab_config_override_dir: 'none', - prefab_config_classpath_dir: 'test', - prefab_envs: ['unit_tests'], prefab_datasources: Reforge::Options::DATASOURCES::LOCAL_ONLY, collect_sync_interval: EFFECTIVELY_NEVER, }.freeze diff --git a/test/test_client.rb b/test/test_client.rb index 0ae89a6..4e19bcd 100644 --- a/test/test_client.rb +++ b/test/test_client.rb @@ -24,27 +24,7 @@ class TestClient < Minitest::Test ] ) - def test_get - _, err = capture_io do - client = new_client - assert_equal 'default', client.get('does.not.exist', 'default') - assert_equal 'test sample value', client.get('sample') - assert_equal 123, client.get('sample_int') - end - assert_equal '', err - end - def test_get_with_default - client = new_client - # A `false` value is not replaced with the default - assert_equal false, client.get('false_value', 'red') - - # A falsy value is not replaced with the default - assert_equal 0, client.get('zero_value', 'red') - - # A missing value returns the default - assert_equal 'buckets', client.get('missing_value', 'buckets') - end def test_get_with_missing_default client = new_client @@ -61,83 +41,9 @@ def test_get_with_missing_default assert_nil client.get('missing_value') end - def test_enabled - client = new_client - assert_equal false, client.enabled?('does_not_exist') - assert_equal true, client.enabled?('enabled_flag') - assert_equal false, client.enabled?('disabled_flag') - assert_equal false, client.enabled?('flag_with_a_value') - end - - def test_ff_enabled_with_user_key_match - client = new_client - - ctx = { user: { key: 'jimmy' } } - assert_equal false, client.enabled?('user_key_match', ctx) - assert_equal false, Reforge::Context.with_context(ctx) { client.enabled?('user_key_match') } - - ctx = { user: { key: 'abc123' } } - assert_equal true, client.enabled?('user_key_match', ctx) - assert_equal true, Reforge::Context.with_context(ctx) { client.enabled?('user_key_match') } - - ctx = { user: { key: 'xyz987' } } - assert_equal true, client.enabled?('user_key_match', ctx) - assert_equal true, Reforge::Context.with_context(ctx) { client.enabled?('user_key_match') } - end - - # NOTE: these are all `false` because we're doing a enabled? on a FF with string variants - # see test_ff_get_with_context for the raw value tests - def test_ff_enabled_with_context - client = new_client - - ctx = { user: { domain: 'gmail.com' } } - assert_equal false, client.enabled?('just_my_domain', ctx) - assert_equal false, Reforge::Context.with_context(ctx) { client.enabled?('just_my_domain') } - - ctx = { user: { domain: 'prefab.cloud' } } - assert_equal false, client.enabled?('just_my_domain', ctx) - assert_equal false, Reforge::Context.with_context(ctx) { client.enabled?('just_my_domain') } - - ctx = { user: { domain: 'example.com' } } - assert_equal false, client.enabled?('just_my_domain', ctx) - assert_equal false, Reforge::Context.with_context(ctx) { client.enabled?('just_my_domain') } - end - - def test_ff_get_with_context - client = new_client - - ctx = { user: { domain: 'gmail.com' } } - assert_equal 'DEFAULT', client.get('just_my_domain', 'DEFAULT', ctx) - assert_equal 'DEFAULT', Reforge::Context.with_context(ctx) { client.get('just_my_domain', 'DEFAULT') } - ctx = { user: { domain: 'prefab.cloud' } } - assert_equal 'new-version', client.get('just_my_domain', 'DEFAULT', ctx) - assert_equal 'new-version', Reforge::Context.with_context(ctx) { client.get('just_my_domain', 'DEFAULT') } - ctx = { user: { domain: 'example.com' } } - assert_equal 'new-version', client.get('just_my_domain', 'DEFAULT', ctx) - assert_equal 'new-version', Reforge::Context.with_context(ctx) { client.get('just_my_domain', 'DEFAULT') } - end - - def test_deprecated_no_dot_notation_ff_enabled_with_jit_context - client = new_client - # with no lookup key - assert_equal false, client.enabled?('deprecated_no_dot_notation', { domain: 'gmail.com' }) - assert_equal true, client.enabled?('deprecated_no_dot_notation', { domain: 'prefab.cloud' }) - assert_equal true, client.enabled?('deprecated_no_dot_notation', { domain: 'example.com' }) - - assert_stderr [ - "[DEPRECATION] Prefab contexts should be a hash with a key of the context name and a value of a hash.", - "[DEPRECATION] Prefab contexts should be a hash with a key of the context name and a value of a hash.", - "[DEPRECATION] Prefab contexts should be a hash with a key of the context name and a value of a hash." - ] - end - def test_getting_feature_flag_value - client = new_client - assert_equal false, client.enabled?('flag_with_a_value') - assert_equal 'all-features', client.get('flag_with_a_value') - end def test_initialization_with_an_options_object options_hash = { @@ -411,21 +317,7 @@ def test_get_log_level assert_summary client, {} end - def test_defined - client = new_client - refute client.defined?('does_not_exist') - assert client.defined?('sample_int') - assert client.defined?('disabled_flag') - end - - def test_is_ff - client = new_client - - assert client.is_ff?('flag_with_a_value') - refute client.is_ff?('sample_int') - refute client.is_ff?('does_not_exist') - end def test_with_datafile datafile = "#{Dir.pwd}/test/fixtures/datafile.json" diff --git a/test/test_config_client.rb b/test/test_config_client.rb index 9355b6e..76e84ee 100644 --- a/test/test_config_client.rb +++ b/test/test_config_client.rb @@ -6,9 +6,6 @@ class TestConfigClient < Minitest::Test def setup super options = Reforge::Options.new( - prefab_config_override_dir: 'none', - prefab_config_classpath_dir: 'test', - prefab_envs: 'unit_tests', prefab_datasources: Reforge::Options::DATASOURCES::LOCAL_ONLY, x_use_local_cache: true, ) @@ -16,13 +13,6 @@ def setup @config_client = Reforge::ConfigClient.new(MockBaseClient.new(options), 10) end - def test_load - assert_equal 'test sample value', @config_client.get('sample') - assert_equal 123, @config_client.get('sample_int') - assert_equal 12.12, @config_client.get('sample_double') - assert_equal true, @config_client.get('sample_bool') - assert_equal :ERROR, @config_client.get('log-level.app') - end def test_initialization_timeout_error options = Reforge::Options.new( @@ -37,20 +27,6 @@ def test_initialization_timeout_error assert_match(/couldn't initialize in 0.01 second timeout/, err.message) end - def test_prefab_envs_is_forgiving - assert_equal ['my_env'], Reforge::Options.new( - prefab_envs: 'my_env' - ).prefab_envs - - assert_equal %w[my_env a_second_env], Reforge::Options.new( - prefab_envs: %w[my_env a_second_env] - ).prefab_envs - end - - def test_prefab_envs_env_var - ENV['PREFAB_ENVS'] = 'one,two' - assert_equal %w[one two], Reforge::Options.new.prefab_envs - end def test_invalid_api_key_error options = Reforge::Options.new( diff --git a/test/test_config_loader.rb b/test/test_config_loader.rb index e62b8d7..674d187 100644 --- a/test/test_config_loader.rb +++ b/test/test_config_loader.rb @@ -6,42 +6,13 @@ class TestConfigLoader < Minitest::Test def setup super options = Reforge::Options.new( - prefab_config_override_dir: 'none', - prefab_config_classpath_dir: 'test', - prefab_envs: 'unit_tests' ) @loader = Reforge::ConfigLoader.new(MockBaseClient.new(options)) end - def test_load - should_be :int, 123, 'sample_int' - should_be :string, 'test sample value', 'sample' - should_be :bool, true, 'sample_bool' - should_be :double, 12.12, 'sample_double' - end - def test_nested - should_be :string, 'nested value', 'nested.values.string' - should_be :string, 'top level', 'nested.values' - should_be :log_level, :ERROR, 'log-level.app' - should_be :log_level, :WARN, 'log-level.app.controller.hello' - should_be :log_level, :INFO, 'log-level.app.controller.hello.index' - end - def test_invalid_log_level - should_be :log_level, :NOT_SET_LOG_LEVEL, 'log-level.invalid' - end - def test_load_without_unit_test_env - options = Reforge::Options.new( - prefab_config_override_dir: 'none', - prefab_config_classpath_dir: 'test' - # no prefab_envs - ) - @loader = Reforge::ConfigLoader.new(MockBaseClient.new(options)) - should_be :string, 'default sample value', 'sample' - should_be :bool, true, 'sample_bool' - end def test_highwater assert_equal 0, @loader.highwater_mark @@ -75,12 +46,6 @@ def test_keeps_most_recent should_be :int, 4, 'sample_int' end - def test_api_precedence - should_be :int, 123, 'sample_int' - - @loader.set(PrefabProto::Config.new(key: 'sample_int', rows: [config_row(PrefabProto::ConfigValue.new(int: 456))]), 'test') - should_be :int, 456, 'sample_int' - end def test_api_deltas val = PrefabProto::ConfigValue.new(int: 456) diff --git a/test/test_feature_flag_client.rb b/test/test_feature_flag_client.rb index 1375382..f07727b 100644 --- a/test/test_feature_flag_client.rb +++ b/test/test_feature_flag_client.rb @@ -5,40 +5,8 @@ class TestFeatureFlagClient < Minitest::Test DEFAULT = 'default' - def test_feature_is_on - ff_client = new_client - assert_equal false, ff_client.feature_is_on?('something-that-does-not-exist') - assert_equal false, ff_client.feature_is_on?('disabled_flag') - assert_equal true, ff_client.feature_is_on?('enabled_flag') - assert_equal false, ff_client.feature_is_on?('flag_with_a_value') - end - - def test_feature_is_on_for - ff_client = new_client - - assert_equal false, ff_client.feature_is_on_for?('something-that-does-not-exist', {}) - assert_equal false, ff_client.feature_is_on_for?('user_key_match', {}) - assert_equal false, ff_client.feature_is_on_for?('user_key_match', { user: { key: 'not-included' } }) - assert_equal true, ff_client.feature_is_on_for?('user_key_match', { user: { key: 'abc123' } }) - assert_equal true, ff_client.feature_is_on_for?('user_key_match', { user: { key: 'xyz987' } }) - end - def test_get - ff_client = new_client - - # No default - assert_equal false, ff_client.get('something-that-does-not-exist', {}) - assert_equal false, ff_client.get('disabled_flag', {}) - assert_equal true, ff_client.get('enabled_flag', {}) - assert_equal 'all-features', ff_client.get('flag_with_a_value', {}) - - # with defaults - assert_equal DEFAULT, ff_client.get('something-that-does-not-exist', {}, default: DEFAULT) - assert_equal false, ff_client.get('disabled_flag', {}, default: DEFAULT) - assert_equal true, ff_client.get('enabled_flag', {}, default: DEFAULT) - assert_equal 'all-features', ff_client.get('flag_with_a_value', {}, default: DEFAULT) - end private diff --git a/test/test_javascript_stub.rb b/test/test_javascript_stub.rb index f154cae..b091705 100644 --- a/test/test_javascript_stub.rb +++ b/test/test_javascript_stub.rb @@ -103,8 +103,6 @@ def setup config: [log_level, config_for_sdk, config_not_for_sdk, ff, json_config, duration_config], project_env_id: PROJECT_ENV_ID, collect_evaluation_summaries: true, - prefab_config_override_dir: '/tmp', - prefab_config_classpath_dir: '/tmp', context_upload_mode: :periodic_example, allow_telemetry_in_local_mode: true ) diff --git a/test/test_prefab.rb b/test/test_prefab.rb index 9d751e5..76a5a07 100644 --- a/test/test_prefab.rb +++ b/test/test_prefab.rb @@ -3,36 +3,8 @@ require 'test_helper' class TestPrefab < Minitest::Test - def test_get - init_once - assert_equal 'default', Reforge.get('does.not.exist', 'default') - assert_equal 'default', Reforge.get('does.not.exist', 'default', { some: { key: 'value' } }) - assert_equal 'test sample value', Reforge.get('sample') - assert_equal 123, Reforge.get('sample_int') - ctx = { user: { key: 'jimmy' } } - assert_equal 'default-goes-here', Reforge.get('user_key_match', 'default-goes-here', ctx) - - ctx = { user: { key: 'abc123' } } - assert_equal true, Reforge.get('user_key_match', nil, ctx) - end - - def test_defined - init_once - - refute Reforge.defined?('does_not_exist') - assert Reforge.defined?('sample_int') - assert Reforge.defined?('disabled_flag') - end - - def test_is_ff - init_once - - assert Reforge.is_ff?('flag_with_a_value') - refute Reforge.is_ff?('sample_int') - refute Reforge.is_ff?('does_not_exist') - end private