Skip to content

Commit 61ecdda

Browse files
committed
WIP
1 parent 6bef49e commit 61ecdda

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

infera/src/http.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,11 @@ mod tests {
482482
let mut server = Server::new();
483483
let body = b"onnxdata".to_vec();
484484

485+
// Use a path unique to this test so the URL hash never collides with other
486+
// tests that mockito may schedule on the same port (OS port reuse).
485487
// 1. Initial request (no ETag matched) returns 200 with ETag "tag1"
486488
let m1 = server
487-
.mock("GET", "/ok_model.onnx")
489+
.mock("GET", "/ok_model_etag_304.onnx")
488490
.match_header("if-none-match", mockito::Matcher::Missing)
489491
.with_status(200)
490492
.with_header("ETag", "tag1")
@@ -493,12 +495,12 @@ mod tests {
493495

494496
// 2. Subsequent request (with If-None-Match: tag1) returns 304 Not Modified
495497
let m2 = server
496-
.mock("GET", "/ok_model.onnx")
498+
.mock("GET", "/ok_model_etag_304.onnx")
497499
.match_header("if-none-match", "tag1")
498500
.with_status(304)
499501
.create();
500502

501-
let url = format!("{}/ok_model.onnx", server.url());
503+
let url = format!("{}/ok_model_etag_304.onnx", server.url());
502504

503505
// First download creates the file and the .etag metadata
504506
let path1 = handle_remote_model(&url).expect("initial download should succeed");
@@ -530,9 +532,11 @@ mod tests {
530532
let body1 = b"onnxdata1".to_vec();
531533
let body2 = b"onnxdata2".to_vec();
532534

535+
// Use a path unique to this test so the URL hash never collides with other
536+
// tests that mockito may schedule on the same port (OS port reuse).
533537
// 1. Initial request returns 200 with ETag "tag1" and body1
534538
let m1 = server
535-
.mock("GET", "/ok_model.onnx")
539+
.mock("GET", "/ok_model_etag_200.onnx")
536540
.match_header("if-none-match", mockito::Matcher::Missing)
537541
.with_status(200)
538542
.with_header("ETag", "tag1")
@@ -541,14 +545,14 @@ mod tests {
541545

542546
// 2. Subsequent request (with If-None-Match: tag1) returns 200 with ETag "tag2" and body2
543547
let m2 = server
544-
.mock("GET", "/ok_model.onnx")
548+
.mock("GET", "/ok_model_etag_200.onnx")
545549
.match_header("if-none-match", "tag1")
546550
.with_status(200)
547551
.with_header("ETag", "tag2")
548552
.with_body(body2.clone())
549553
.create();
550554

551-
let url = format!("{}/ok_model.onnx", server.url());
555+
let url = format!("{}/ok_model_etag_200.onnx", server.url());
552556

553557
// First download gets body1
554558
let path1 = handle_remote_model(&url).expect("initial download should succeed");

0 commit comments

Comments
 (0)