Skip to content

Commit b1c624d

Browse files
committed
Fix test data issue
1 parent 2dc3300 commit b1c624d

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

spec/config/datafile_project_config_spec.rb

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,29 +1425,17 @@
14251425
end
14261426

14271427
describe 'Holdout Decision Functionality' do
1428-
let(:holdout_test_data_path) do
1429-
File.join(File.dirname(__FILE__), 'test_data', 'holdout_test_data.json')
1430-
end
1431-
1432-
let(:holdout_test_data) do
1433-
JSON.parse(File.read(holdout_test_data_path))
1434-
end
1435-
1436-
let(:datafile_with_holdouts) do
1437-
holdout_test_data['datafileWithHoldouts']
1438-
end
1439-
14401428
let(:config_with_holdouts) do
14411429
Optimizely::DatafileProjectConfig.new(
1442-
datafile_with_holdouts,
1430+
OptimizelySpec::CONFIG_BODY_WITH_HOLDOUTS_JSON,
14431431
logger,
14441432
error_handler
14451433
)
14461434
end
14471435

14481436
describe '#decide with global holdout' do
14491437
it 'should return valid decision for global holdout' do
1450-
feature_flag = config_with_holdouts.feature_flag_key_map['test_flag_1']
1438+
feature_flag = config_with_holdouts.feature_flag_key_map['boolean_feature']
14511439
expect(feature_flag).not_to be_nil
14521440

14531441
# Verify holdouts are loaded
@@ -1456,15 +1444,15 @@
14561444
end
14571445

14581446
it 'should handle decision with global holdout configuration' do
1459-
feature_flag = config_with_holdouts.feature_flag_key_map['test_flag_1']
1447+
feature_flag = config_with_holdouts.feature_flag_key_map['boolean_feature']
14601448
expect(feature_flag).not_to be_nil
14611449
expect(feature_flag['id']).not_to be_empty
14621450
end
14631451
end
14641452

14651453
describe '#decide with included flags holdout' do
14661454
it 'should return valid decision for included flags' do
1467-
feature_flag = config_with_holdouts.feature_flag_key_map['test_flag_1']
1455+
feature_flag = config_with_holdouts.feature_flag_key_map['boolean_feature']
14681456
expect(feature_flag).not_to be_nil
14691457

14701458
# Check if there's a holdout that includes this flag
@@ -1479,21 +1467,21 @@
14791467
end
14801468

14811469
it 'should properly filter holdouts based on includedFlags' do
1482-
feature_flag = config_with_holdouts.feature_flag_key_map['test_flag_1']
1470+
feature_flag = config_with_holdouts.feature_flag_key_map['boolean_feature']
14831471
expect(feature_flag).not_to be_nil
14841472

1485-
holdouts_for_flag = config_with_holdouts.get_holdouts_for_flag('test_flag_1')
1473+
holdouts_for_flag = config_with_holdouts.get_holdouts_for_flag('boolean_feature')
14861474
expect(holdouts_for_flag).to be_an(Array)
14871475
end
14881476
end
14891477

14901478
describe '#decide with excluded flags holdout' do
14911479
it 'should not return excluded holdout for excluded flag' do
1492-
# test_flag_3 is excluded by holdout_excluded_1
1493-
feature_flag = config_with_holdouts.feature_flag_key_map['test_flag_3']
1480+
# boolean_feature is excluded by holdout_excluded_1
1481+
feature_flag = config_with_holdouts.feature_flag_key_map['boolean_feature']
14941482

14951483
if feature_flag
1496-
holdouts_for_flag = config_with_holdouts.get_holdouts_for_flag('test_flag_3')
1484+
holdouts_for_flag = config_with_holdouts.get_holdouts_for_flag('boolean_feature')
14971485

14981486
# Should not include holdouts that exclude this flag
14991487
excluded_holdout = holdouts_for_flag.find { |h| h['key'] == 'excluded_holdout' }
@@ -1502,17 +1490,17 @@
15021490
end
15031491

15041492
it 'should return holdouts for non-excluded flag' do
1505-
feature_flag = config_with_holdouts.feature_flag_key_map['test_flag_1']
1493+
feature_flag = config_with_holdouts.feature_flag_key_map['boolean_feature']
15061494
expect(feature_flag).not_to be_nil
15071495

1508-
holdouts_for_flag = config_with_holdouts.get_holdouts_for_flag('test_flag_1')
1496+
holdouts_for_flag = config_with_holdouts.get_holdouts_for_flag('boolean_feature')
15091497
expect(holdouts_for_flag).to be_an(Array)
15101498
end
15111499
end
15121500

15131501
describe '#decide with multiple holdouts' do
15141502
it 'should handle multiple holdouts for different flags' do
1515-
flag_keys = %w[test_flag_1 test_flag_2 test_flag_3 test_flag_4]
1503+
flag_keys = %w[boolean_feature multi_variate_feature string_single_variable_feature empty_feature]
15161504

15171505
flag_keys.each do |flag_key|
15181506
feature_flag = config_with_holdouts.feature_flag_key_map[flag_key]
@@ -1531,8 +1519,8 @@
15311519
end
15321520

15331521
it 'should properly cache holdout lookups' do
1534-
holdouts_1 = config_with_holdouts.get_holdouts_for_flag('test_flag_1')
1535-
holdouts_2 = config_with_holdouts.get_holdouts_for_flag('test_flag_1')
1522+
holdouts_1 = config_with_holdouts.get_holdouts_for_flag('boolean_feature')
1523+
holdouts_2 = config_with_holdouts.get_holdouts_for_flag('boolean_feature')
15361524

15371525
expect(holdouts_1).to equal(holdouts_2)
15381526
end
@@ -1566,18 +1554,18 @@
15661554

15671555
describe '#decide with empty user id' do
15681556
it 'should handle empty user id without error' do
1569-
feature_flag = config_with_holdouts.feature_flag_key_map['test_flag_1']
1557+
feature_flag = config_with_holdouts.feature_flag_key_map['boolean_feature']
15701558
expect(feature_flag).not_to be_nil
15711559

15721560
# Empty user ID should be valid for bucketing
15731561
# This test verifies the config structure supports this
1574-
expect(feature_flag['key']).to eq('test_flag_1')
1562+
expect(feature_flag['key']).to eq('boolean_feature')
15751563
end
15761564
end
15771565

15781566
describe '#holdout priority evaluation' do
15791567
it 'should evaluate global holdouts for flags without specific targeting' do
1580-
feature_flag = config_with_holdouts.feature_flag_key_map['test_flag_1']
1568+
feature_flag = config_with_holdouts.feature_flag_key_map['boolean_feature']
15811569
expect(feature_flag).not_to be_nil
15821570

15831571
global_holdouts = config_with_holdouts.holdouts.select do |h|

0 commit comments

Comments
 (0)