@@ -59,86 +59,86 @@ def test_prepare_data
5959 end
6060
6161 def test_sync
62- awhile_ago = Time . now - 60
63- now = Time . now
62+ Timecop . freeze ( '2023-08-09 15:18:12 -0400' ) do
63+ awhile_ago = Time . now - 60
64+ now = Time . now
6465
65- client = MockBaseClient . new
66+ client = MockBaseClient . new
6667
67- aggregator = nil
68+ aggregator = nil
6869
69- Timecop . freeze ( awhile_ago ) do
70- # start the aggregator in the past
71- aggregator = Prefab ::EvaluationSummaryAggregator . new ( client : client , max_keys : 10 ,
70+ Timecop . freeze ( awhile_ago ) do
71+ # start the aggregator in the past
72+ aggregator = Prefab ::EvaluationSummaryAggregator . new ( client : client , max_keys : 10 ,
7273 sync_interval : EFFECTIVELY_NEVER )
73- end
74-
75- add_example_data ( aggregator )
74+ end
7675
77- expected_post = PrefabProto ::TelemetryEvents . new (
78- instance_hash : client . instance_hash ,
79- events : [
80- PrefabProto ::TelemetryEvent . new (
81- summaries :
82-
83- PrefabProto ::ConfigEvaluationSummaries . new (
84- start : awhile_ago . to_i * 1000 ,
85- end : now . to_i * 1000 ,
86- summaries : [
87- PrefabProto ::ConfigEvaluationSummary . new (
88- key : 'config-1' ,
89- type : :CONFIG ,
90- counters : [
91- PrefabProto ::ConfigEvaluationCounter . new (
92- config_id : 1 ,
93- selected_index : 2 ,
94- config_row_index : 3 ,
95- conditional_value_index : 4 ,
96- weighted_value_index : 5 ,
97- selected_value : EXAMPLE_VALUE_1 ,
98- count : 3
99- ) ,
100- PrefabProto ::ConfigEvaluationCounter . new (
101- config_id : 1 ,
102- selected_index : 3 ,
103- config_row_index : 7 ,
104- conditional_value_index : 8 ,
105- weighted_value_index : 10 ,
106- selected_value : EXAMPLE_VALUE_2 ,
107- count : 1
108- )
109- ]
110- ) ,
111- PrefabProto ::ConfigEvaluationSummary . new (
112- key : 'config-2' ,
113- type : :FEATURE_FLAG ,
114- counters : [
115- PrefabProto ::ConfigEvaluationCounter . new (
116- config_id : 2 ,
117- selected_index : 3 ,
118- config_row_index : 5 ,
119- conditional_value_index : 7 ,
120- weighted_value_index : 6 ,
121- selected_value : EXAMPLE_VALUE_1 ,
122- count : 9
123- )
124- ]
76+ add_example_data ( aggregator )
77+
78+ expected_post = PrefabProto ::TelemetryEvents . new (
79+ instance_hash : client . instance_hash ,
80+ events : [
81+ PrefabProto ::TelemetryEvent . new (
82+ summaries : PrefabProto ::ConfigEvaluationSummaries . new (
83+ start : awhile_ago . to_i * 1000 ,
84+ end : now . to_i * 1000 ,
85+ summaries : [
86+ PrefabProto ::ConfigEvaluationSummary . new (
87+ key : 'config-1' ,
88+ type : :CONFIG ,
89+ counters : [
90+ PrefabProto ::ConfigEvaluationCounter . new (
91+ config_id : 1 ,
92+ selected_index : 2 ,
93+ config_row_index : 3 ,
94+ conditional_value_index : 4 ,
95+ weighted_value_index : 5 ,
96+ selected_value : EXAMPLE_VALUE_1 ,
97+ count : 3
98+ ) ,
99+ PrefabProto ::ConfigEvaluationCounter . new (
100+ config_id : 1 ,
101+ selected_index : 3 ,
102+ config_row_index : 7 ,
103+ conditional_value_index : 8 ,
104+ weighted_value_index : 10 ,
105+ selected_value : EXAMPLE_VALUE_2 ,
106+ count : 1
107+ )
108+ ]
109+ ) ,
110+ PrefabProto ::ConfigEvaluationSummary . new (
111+ key : 'config-2' ,
112+ type : :FEATURE_FLAG ,
113+ counters : [
114+ PrefabProto ::ConfigEvaluationCounter . new (
115+ config_id : 2 ,
116+ selected_index : 3 ,
117+ config_row_index : 5 ,
118+ conditional_value_index : 7 ,
119+ weighted_value_index : 6 ,
120+ selected_value : EXAMPLE_VALUE_1 ,
121+ count : 9
122+ )
123+ ]
124+ )
125+ ]
126+ )
125127 )
126128 ]
127129 )
128- )
129- ]
130- )
131130
132- requests = wait_for_post_requests ( client ) do
133- Timecop . freeze ( now ) do
134- aggregator . sync
131+ requests = wait_for_post_requests ( client ) do
132+ Timecop . freeze ( now ) do
133+ aggregator . sync
134+ end
135135 end
136- end
137136
138- assert_equal [ [
139- '/api/v1/telemetry' ,
140- expected_post
141- ] ] , requests
137+ assert_equal [ [
138+ '/api/v1/telemetry' ,
139+ expected_post
140+ ] ] , requests
141+ end
142142 end
143143
144144 private
0 commit comments