-
Notifications
You must be signed in to change notification settings - Fork 42
test: create a test for m0002010 using DS4 #2243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1ae5378
aa99c38
8e01ade
aef34f4
4a0d791
41d7b95
4b576b8
bebe1c1
1593da0
a99181f
a0cce26
903dc29
a605b64
c567d56
0afe38d
4946ef6
f47d81c
1293af9
37c5ce8
51a672a
0de986f
fc85e6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,7 @@ jobs: | |
|
|
||
| - name: Test | ||
| # use only one job, trying to reduce memory usage | ||
| run: cargo llvm-cov --codecov --jobs 1 --features _test-s3 --output-path codecov.json | ||
| run: cargo llvm-cov --codecov --jobs 1 --all-features --output-path codecov.json | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| env: | ||
| GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # for embedded postgresql | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,8 @@ | ||
| use anyhow::Context; | ||
| use postgresql_embedded::{PostgreSQL, Settings, VersionReq}; | ||
| use std::{ | ||
| path::{Path, PathBuf}, | ||
| pin::Pin, | ||
| }; | ||
| use tokio::io::{AsyncRead, BufReader}; | ||
| use std::path::{Path, PathBuf}; | ||
| use tracing::{Instrument, info_span}; | ||
| use trustify_common::db::Database; | ||
| use trustify_common::{db::Database, decompress::decompress_async_read}; | ||
|
|
||
| /// Create common default settings for the embedded database | ||
| pub fn default_settings() -> anyhow::Result<Settings> { | ||
|
|
@@ -76,33 +72,16 @@ pub async fn create_for( | |
| .instrument(info_span!("start database")) | ||
| .await?; | ||
|
|
||
| let config = crate::config::Database { | ||
| username: "postgres".into(), | ||
| password: "trustify".into(), | ||
| host: "localhost".into(), | ||
| name: "test".into(), | ||
| port: postgresql.settings().port, | ||
| ..crate::config::Database::from_env()? | ||
| }; | ||
| let config = crate::config::Database::from_port(postgresql.settings().port)?; | ||
|
|
||
| let db = match options.source { | ||
| Source::Bootstrap => super::Database::bootstrap(&config) | ||
| .await | ||
| .context("Bootstrapping the test database")?, | ||
| Source::Import(path) => { | ||
| log::info!("Importing from: {}", path.display()); | ||
|
|
||
| let source = tokio::fs::File::open(&path).await?; | ||
| let source = BufReader::new(source); | ||
| log::info!("Importing database from: {}", path.display()); | ||
|
|
||
| let source: Pin<Box<dyn AsyncRead + Send>> = match path | ||
| .extension() | ||
| .and_then(|ext| ext.to_str()) | ||
| { | ||
| None | Some("sql") => Box::pin(source), | ||
| Some("xz") => Box::pin(async_compression::tokio::bufread::LzmaDecoder::new(source)), | ||
| Some(ext) => anyhow::bail!("Unsupported file type ({ext})"), | ||
| }; | ||
| let source = decompress_async_read(path).await?; | ||
|
Comment on lines
+82
to
+84
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (bug_risk): Change from failing on unsupported extensions to transparently passing them through may hide format errors The previous logic failed fast on unsupported extensions, giving clear feedback for cases like Suggested implementation: Source::Import(path) => {
log::info!("Importing database from: {}", path.display());
// Enforce an allowlist of supported file extensions to fail fast on unexpected formats.
match path.extension().and_then(|ext| ext.to_str()) {
None | Some("sql") | Some("xz") => {}
Some(ext) => anyhow::bail!("Unsupported file type ({ext})"),
}
let source = decompress_async_read(path).await?;
super::Database::import(&config, source)
.awaitIf |
||
|
|
||
| super::Database::import(&config, source) | ||
| .await | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍