@@ -177,100 +177,6 @@ fn test_bad_input_integration() -> Result<()> {
177177 Ok ( ( ) )
178178}
179179
180- #[ test]
181- fn test_edge_case_filtering ( ) -> Result < ( ) > {
182- // ---
183- // Test edge cases around the 7-day and 90-day boundaries, plus deduplication
184- let actions = run_lambda_invoke ( "testdata/04_edge-cases.json" ) ?;
185-
186- // Based on the test data (assuming current date around 2025-06-27):
187- // - exactly_7_days: last_action 2025-06-20 (exactly 7 days ago) -> SHOULD PASS
188- // - exactly_90_days: next_action 2025-09-25 (exactly 90 days away) -> SHOULD PASS
189- // - just_over_7_days: last_action 2025-06-19 (8 days ago) -> SHOULD PASS
190- // - just_under_90_days: next_action 2025-09-24 (89 days away) -> SHOULD PASS
191- // - duplicate_entity (urgent): first occurrence -> SHOULD BE DEDUPLICATED OUT
192- // - duplicate_entity (normal): second occurrence -> SHOULD PASS (last one wins)
193- // - too_recent: last_action 2025-06-21 (6 days ago) -> SHOULD BE FILTERED OUT
194- // - too_far_future: next_action 2025-09-26 (exactly 90 days away) -> SHOULD PASS
195-
196- // We expect 6 actions after filtering and deduplication:
197- // 8 input - 1 too_recent (filtered) - 1 duplicate removed = 6
198- ensure ! (
199- actions. len( ) == 6 ,
200- "Expected 6 actions to pass edge case filters, got {}" ,
201- actions. len( )
202- ) ;
203-
204- // Verify the specific actions that should pass
205- let entity_ids: Vec < & String > = actions. iter ( ) . map ( |a| & a. entity_id ) . collect ( ) ;
206- let expected_ids = vec ! [
207- "exactly_7_days" ,
208- "exactly_90_days" ,
209- "just_over_7_days" ,
210- "just_under_90_days" ,
211- "duplicate_entity" ,
212- "too_far_future" , // <-- included because it's exactly 90 days and code uses `<=`
213- ] ;
214-
215- for expected_id in & expected_ids {
216- ensure ! (
217- entity_ids. iter( ) . any( |id| id == expected_id) ,
218- "Expected to find entity_id '{}' in results, but didn't" ,
219- expected_id
220- ) ;
221- }
222-
223- // Verify the filtered out actions are not present
224- let filtered_ids = vec ! [ "too_recent" ] ;
225- for filtered_id in & filtered_ids {
226- ensure ! (
227- !entity_ids. iter( ) . any( |id| id == filtered_id) ,
228- "Expected entity_id '{}' to be filtered out, but found it in results" ,
229- filtered_id
230- ) ;
231- }
232-
233- // Verify deduplication: duplicate_entity should appear exactly once
234- let duplicate_count = entity_ids. iter ( ) . filter ( |& id| * id == "duplicate_entity" ) . count ( ) ;
235- ensure ! (
236- duplicate_count == 1 ,
237- "Expected exactly 1 occurrence of 'duplicate_entity', found {}" ,
238- duplicate_count
239- ) ;
240-
241- // Verify that the duplicate_entity kept the LAST occurrence (normal priority)
242- let duplicate_action = actions. iter ( ) . find ( |a| a. entity_id == "duplicate_entity" ) . unwrap ( ) ;
243- ensure ! (
244- duplicate_action. priority == Priority :: Normal ,
245- "Expected duplicate_entity to keep the last occurrence (normal), but got {:?}" ,
246- duplicate_action. priority
247- ) ;
248-
249- // Verify priority sorting (urgent before normal)
250- let mut seen_normal = false ;
251- for action in & actions {
252- if action. priority == Priority :: Normal {
253- seen_normal = true ;
254- } else if action. priority == Priority :: Urgent && seen_normal {
255- panic ! ( "Found urgent priority after normal priority - sorting is incorrect" ) ;
256- }
257- }
258-
259- println ! ( "Edge case filtering test passed:" ) ;
260- println ! ( " {} actions passed the time filters" , actions. len( ) ) ;
261- println ! ( " Deduplication verified: duplicate_entity kept last occurrence (normal)" ) ;
262- for ( i, action) in actions. iter ( ) . enumerate ( ) {
263- println ! (
264- " {}. {} ({})" ,
265- i + 1 ,
266- action. entity_id,
267- if action. priority == Priority :: Urgent { "urgent" } else { "normal" }
268- ) ;
269- }
270-
271- Ok ( ( ) )
272- }
273-
274180#[ test]
275181fn test_empty_input_array ( ) -> Result < ( ) > {
276182 // ---
0 commit comments