Skip to content

Commit 57a92a8

Browse files
committed
small impr
1 parent b368e46 commit 57a92a8

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

url_finder/src/background/url_discovery_scheduler.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ async fn schedule_url_discoveries(
9393
test_provider_with_clients(config, &provider.provider_id, clients, deal_repo).await;
9494

9595
// Extract provider-only result for storage_providers update
96+
// None case: provider-only discovery missing (panic, filtering, etc.) - default is_consistent
97+
// to false since consistency was not verified
9698
let provider_discovery = results.iter().find(|r| r.client_id.is_none());
9799

98100
let (last_working_url, is_consistent, is_reliable, url_metadata) = match provider_discovery
@@ -103,7 +105,7 @@ async fn schedule_url_discoveries(
103105
r.is_reliable,
104106
r.url_metadata.clone(),
105107
),
106-
None => (None, true, false, None),
108+
None => (None, false, false, None),
107109
};
108110

109111
let url_results: Vec<UrlResult> = results.into_iter().map(|r| r.into()).collect();

url_finder/tests/integration_tests/bms_result_repo.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ async fn test_get_history_for_provider() {
307307

308308
let provider = provider_id(TEST_PROVIDER_1_DB);
309309

310-
// Insert 3 results
310+
// Insert 3 results with small delays to ensure unique timestamps
311311
for i in 0..3 {
312312
let job_id = Uuid::new_v4();
313313
repo.insert_pending(&provider, job_id, TEST_WORKING_URL, "us_east", 3)
@@ -316,16 +316,22 @@ async fn test_get_history_for_provider() {
316316
repo.update_completed(job_id, "Completed", Some(10.0 + i as f64), None, None, None)
317317
.await
318318
.unwrap();
319+
// Sleep between iterations to ensure unique created_at timestamps
320+
// so the ordering assertion is meaningfully validated
321+
if i < 2 {
322+
tokio::time::sleep(tokio::time::Duration::from_millis(2)).await;
323+
}
319324
}
320325

321326
// Get history with limit 2
322327
let history = repo.get_history_for_provider(&provider, 2).await.unwrap();
323328

324329
assert_eq!(history.len(), 2);
325330
// Verify ordered by created_at DESC (most recent first)
331+
// Use strict inequality to confirm timestamps are actually different
326332
assert!(
327-
history[0].created_at >= history[1].created_at,
328-
"History should be ordered by created_at DESC: first={:?}, second={:?}",
333+
history[0].created_at > history[1].created_at,
334+
"History should be ordered by created_at DESC with distinct timestamps: first={:?}, second={:?}",
329335
history[0].created_at,
330336
history[1].created_at
331337
);

url_finder/tests/integration_tests/extended_response.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,19 @@ async fn test_get_provider_extended_response_has_scheduling() {
191191
);
192192

193193
// scheduling should be present when SP record exists
194-
let scheduling = body.get("scheduling");
195-
if let Some(sched) = scheduling {
196-
// Verify scheduling structure
197-
assert!(
198-
sched.get("url_discovery").is_some(),
199-
"scheduling.url_discovery should exist"
200-
);
201-
assert!(
202-
sched.get("bms_test").is_some(),
203-
"scheduling.bms_test should exist"
204-
);
205-
}
194+
let scheduling = body
195+
.get("scheduling")
196+
.expect("scheduling should be present in extended response");
197+
198+
// Verify scheduling structure
199+
assert!(
200+
scheduling.get("url_discovery").is_some(),
201+
"scheduling.url_discovery should exist"
202+
);
203+
assert!(
204+
scheduling.get("bms_test").is_some(),
205+
"scheduling.bms_test should exist"
206+
);
206207
}
207208

208209
#[tokio::test]

0 commit comments

Comments
 (0)