From 65f458386e84979807e1920e1ba9687cedf18286 Mon Sep 17 00:00:00 2001 From: James Kebinger Date: Tue, 15 Apr 2025 11:28:12 -0500 Subject: [PATCH] restore the removed Timecop.freeze call for this test comparing timestamps --- test/test_evaluation_summary_aggregator.rb | 138 ++++++++++----------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/test/test_evaluation_summary_aggregator.rb b/test/test_evaluation_summary_aggregator.rb index 3ceafb9c..fa569a5f 100644 --- a/test/test_evaluation_summary_aggregator.rb +++ b/test/test_evaluation_summary_aggregator.rb @@ -59,86 +59,86 @@ def test_prepare_data end def test_sync - awhile_ago = Time.now - 60 - now = Time.now + Timecop.freeze('2023-08-09 15:18:12 -0400') do + awhile_ago = Time.now - 60 + now = Time.now - client = MockBaseClient.new + client = MockBaseClient.new - aggregator = nil + aggregator = nil - Timecop.freeze(awhile_ago) do - # start the aggregator in the past - aggregator = Prefab::EvaluationSummaryAggregator.new(client: client, max_keys: 10, + Timecop.freeze(awhile_ago) do + # start the aggregator in the past + aggregator = Prefab::EvaluationSummaryAggregator.new(client: client, max_keys: 10, sync_interval: EFFECTIVELY_NEVER) - end - - add_example_data(aggregator) + end - expected_post = PrefabProto::TelemetryEvents.new( - instance_hash: client.instance_hash, - events: [ - PrefabProto::TelemetryEvent.new( - summaries: - - PrefabProto::ConfigEvaluationSummaries.new( - start: awhile_ago.to_i * 1000, - end: now.to_i * 1000, - summaries: [ - PrefabProto::ConfigEvaluationSummary.new( - key: 'config-1', - type: :CONFIG, - counters: [ - PrefabProto::ConfigEvaluationCounter.new( - config_id: 1, - selected_index: 2, - config_row_index: 3, - conditional_value_index: 4, - weighted_value_index: 5, - selected_value: EXAMPLE_VALUE_1, - count: 3 - ), - PrefabProto::ConfigEvaluationCounter.new( - config_id: 1, - selected_index: 3, - config_row_index: 7, - conditional_value_index: 8, - weighted_value_index: 10, - selected_value: EXAMPLE_VALUE_2, - count: 1 - ) - ] - ), - PrefabProto::ConfigEvaluationSummary.new( - key: 'config-2', - type: :FEATURE_FLAG, - counters: [ - PrefabProto::ConfigEvaluationCounter.new( - config_id: 2, - selected_index: 3, - config_row_index: 5, - conditional_value_index: 7, - weighted_value_index: 6, - selected_value: EXAMPLE_VALUE_1, - count: 9 - ) - ] + add_example_data(aggregator) + + expected_post = PrefabProto::TelemetryEvents.new( + instance_hash: client.instance_hash, + events: [ + PrefabProto::TelemetryEvent.new( + summaries: PrefabProto::ConfigEvaluationSummaries.new( + start: awhile_ago.to_i * 1000, + end: now.to_i * 1000, + summaries: [ + PrefabProto::ConfigEvaluationSummary.new( + key: 'config-1', + type: :CONFIG, + counters: [ + PrefabProto::ConfigEvaluationCounter.new( + config_id: 1, + selected_index: 2, + config_row_index: 3, + conditional_value_index: 4, + weighted_value_index: 5, + selected_value: EXAMPLE_VALUE_1, + count: 3 + ), + PrefabProto::ConfigEvaluationCounter.new( + config_id: 1, + selected_index: 3, + config_row_index: 7, + conditional_value_index: 8, + weighted_value_index: 10, + selected_value: EXAMPLE_VALUE_2, + count: 1 + ) + ] + ), + PrefabProto::ConfigEvaluationSummary.new( + key: 'config-2', + type: :FEATURE_FLAG, + counters: [ + PrefabProto::ConfigEvaluationCounter.new( + config_id: 2, + selected_index: 3, + config_row_index: 5, + conditional_value_index: 7, + weighted_value_index: 6, + selected_value: EXAMPLE_VALUE_1, + count: 9 + ) + ] + ) + ] + ) ) ] ) - ) - ] - ) - requests = wait_for_post_requests(client) do - Timecop.freeze(now) do - aggregator.sync + requests = wait_for_post_requests(client) do + Timecop.freeze(now) do + aggregator.sync + end end - end - assert_equal [[ - '/api/v1/telemetry', - expected_post - ]], requests + assert_equal [[ + '/api/v1/telemetry', + expected_post + ]], requests + end end private