Skip to content

Commit 9be9366

Browse files
committed
Fix and improved bootstrap jobs module test.
On O.S. with different language than english the BadTlsConfig source error message will differ from the compared one. This will fix this issue by matching the enum itself instead of relying on a string compare.
1 parent 5478c3d commit 9be9366

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/bootstrap/jobs/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mod tests {
5050
use camino::Utf8PathBuf;
5151
use torrust_tracker_configuration::TslConfig;
5252

53-
use super::make_rust_tls;
53+
use super::{make_rust_tls, Error};
5454

5555
#[tokio::test]
5656
async fn it_should_error_on_bad_tls_config() {
@@ -65,9 +65,7 @@ mod tests {
6565
.expect("tls_was_enabled")
6666
.expect_err("bad_cert_and_key_files");
6767

68-
assert!(err
69-
.to_string()
70-
.contains("bad tls config: No such file or directory (os error 2)"));
68+
assert!(matches!(err, Error::BadTlsConfig { source: _ }));
7169
}
7270

7371
#[tokio::test]
@@ -83,7 +81,7 @@ mod tests {
8381
.expect("tls_was_enabled")
8482
.expect_err("missing_config");
8583

86-
assert_eq!(err.to_string(), "tls config missing");
84+
assert!(matches!(err, Error::MissingTlsConfig { location: _ }));
8785
}
8886
}
8987

0 commit comments

Comments
 (0)