Skip to content

Commit 76ffa87

Browse files
peco-engineer-bot[bot]vikrantpuppala
authored andcommitted
ai: apply changes for #183 (1 review thread)
Addresses: - #3626177132 at tests/v0_metadata_wiremock.rs:780 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent 73a72da commit 76ffa87

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

‎tests/v0_metadata_wiremock.rs‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,3 +1235,52 @@ async fn metadata_succeeded_response_still_closes_statement() {
12351235
tokio::time::sleep(std::time::Duration::from_millis(150)).await;
12361236
// `_close` verifies expect(1) when it drops at end of scope.
12371237
}
1238+
1239+
/// Same CLOSED-skip guarantee as
1240+
/// [`metadata_closed_response_skips_close_statement`], but exercised
1241+
/// through `list_tables()` rather than `list_catalogs()`. Unlike
1242+
/// `list_catalogs` (which takes the no-error early-`?` path), the other
1243+
/// metadata methods route the transport result through a
1244+
/// `match { Ok(r) => r, Err(e) => return not_found_or(...) }` before
1245+
/// reaching the shared `close_id` reshape. This test guards that more
1246+
/// common code shape so a future refactor that reorders the
1247+
/// `close_id`/reshape sequence on a `match`-branch method still gets
1248+
/// caught.
1249+
#[tokio::test]
1250+
async fn metadata_closed_response_skips_close_statement_on_match_branch() {
1251+
let server = MockServer::start().await;
1252+
mount_create_session(&server).await;
1253+
mount_delete_session(&server).await;
1254+
1255+
let raw = string_batch(vec![
1256+
("namespace", vec![Some("default")]),
1257+
("tableName", vec![Some("t1")]),
1258+
("catalogName", vec![Some("main")]),
1259+
("tableType", vec![Some("TABLE")]),
1260+
]);
1261+
// Inline result with status.state == CLOSED — server already closed it.
1262+
mount_execute(&server, closed_inline_response_body(&raw)).await;
1263+
1264+
// Scoped expectation: NO DELETE on the statement endpoint.
1265+
let _no_close = Mock::given(method("DELETE"))
1266+
.and(path("/api/2.0/sql/statements/stmt-test"))
1267+
.respond_with(ResponseTemplate::new(200).set_body_string("{}"))
1268+
.expect(0)
1269+
.mount_as_scoped(&server)
1270+
.await;
1271+
1272+
let session = open_session(&server).await;
1273+
{
1274+
let mut stream = session
1275+
.metadata()
1276+
.list_tables(None, None, None, None)
1277+
.await
1278+
.expect("list_tables");
1279+
let _ = drain_stream(&mut stream).await;
1280+
// stream drops here — a redundant close guard would fire now.
1281+
}
1282+
// Give any (erroneously) spawned fire-and-forget close a chance to
1283+
// hit the wire before the scoped mock verifies expect(0) on drop.
1284+
tokio::time::sleep(std::time::Duration::from_millis(150)).await;
1285+
// `_no_close` verifies expect(0) when it drops at end of scope.
1286+
}

0 commit comments

Comments
 (0)