Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa10e3c

Browse files
Merge pull request #217 from theseus-rs/prevent-bundled-network-access
fix: always use the build version of postgresql when the bundled feature is enabled to avoid network access
2 parents a7bd101 + ba51a9b commit aa10e3c

File tree

19 files changed

+82
-41
lines changed

19 files changed

+82
-41
lines changed

examples/archive_async/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mod test {
2525
use super::*;
2626

2727
#[test]
28-
fn test_main() -> Result<()> {
28+
fn test_archive_async_main() -> Result<()> {
2929
main()
3030
}
3131
}

examples/archive_sync/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mod test {
2525
use super::*;
2626

2727
#[test]
28-
fn test_main() -> Result<()> {
28+
fn test_archive_sync_main() -> Result<()> {
2929
main()
3030
}
3131
}

examples/diesel_embedded/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mod test {
7272
use super::*;
7373

7474
#[test]
75-
fn test_main() -> Result<()> {
75+
fn test_diesel_embedded_main() -> Result<()> {
7676
main()
7777
}
7878
}

examples/download_progress_bar/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ mod test {
4343
use super::*;
4444

4545
#[test]
46-
fn test_main() -> Result<()> {
46+
fn test_download_progress_bar_main() -> Result<()> {
4747
main()
4848
}
4949
}

examples/embedded_async/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod test {
2727
use super::*;
2828

2929
#[test]
30-
fn test_main() -> Result<()> {
30+
fn test_embedded_async_main() -> Result<()> {
3131
main()
3232
}
3333
}

examples/embedded_sync/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod test {
2323
use super::*;
2424

2525
#[test]
26-
fn test_main() -> Result<()> {
26+
fn test_embedded_sync_main() -> Result<()> {
2727
main()
2828
}
2929
}

examples/portal_corp_extension/src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,22 @@ async fn main() -> Result<()> {
1818
tracing_subscriber::fmt().compact().init();
1919

2020
info!("Installing PostgreSQL");
21+
let postgresql_version = VersionReq::parse("=16.4.0")?;
2122
let settings = Settings {
22-
version: VersionReq::parse("=16.4.0")?,
23+
version: postgresql_version.clone(),
2324
..Default::default()
2425
};
2526
let mut postgresql = PostgreSQL::new(settings);
2627
postgresql.setup().await?;
2728

29+
let settings = postgresql.settings();
30+
// Skip the test if the PostgreSQL version does not match; when testing with the 'bundled'
31+
// feature, the version may vary and the test will fail.
32+
if settings.version != postgresql_version {
33+
eprintln!("Postgresql version does not match");
34+
return Ok(());
35+
}
36+
2837
info!("Installing the vector extension from PortalCorp");
2938
postgresql_extensions::install(
3039
postgresql.settings(),
@@ -120,10 +129,12 @@ async fn execute_query(pool: &PgPool, query: &str) -> Result<()> {
120129

121130
#[cfg(test)]
122131
mod test {
132+
#[cfg(not(all(target_os = "linux", target_arch = "x86_64")))]
123133
use super::*;
124134

135+
#[cfg(not(all(target_os = "linux", target_arch = "x86_64")))]
125136
#[test]
126-
fn test_main() -> Result<()> {
137+
fn test_portal_corp_extension_main() -> Result<()> {
127138
main()
128139
}
129140
}

examples/postgres_embedded/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ mod test {
9393
use super::*;
9494

9595
#[test]
96-
fn test_main() -> Result<()> {
96+
fn test_postgres_embedded_main() -> Result<()> {
9797
main()
9898
}
9999
}

examples/sqlx_embedded/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mod test {
9292
use super::*;
9393

9494
#[test]
95-
fn test_main() -> Result<()> {
95+
fn test_sqlx_embedded_main() -> Result<()> {
9696
main()
9797
}
9898
}

examples/tensor_chord_extension/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,14 @@ async fn execute_query(pool: &PgPool, query: &str) -> Result<()> {
147147
Ok(())
148148
}
149149

150-
#[cfg(target_os = "linux")]
151150
#[cfg(test)]
152151
mod test {
152+
#[cfg(not(all(target_os = "linux", target_arch = "x86_64")))]
153153
use super::*;
154154

155+
#[cfg(not(all(target_os = "linux", target_arch = "x86_64")))]
155156
#[test]
156-
fn test_main() -> Result<()> {
157+
fn test_tensor_chord_extension_main() -> Result<()> {
157158
main()
158159
}
159160
}

0 commit comments

Comments
 (0)