Skip to content
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

fix: typo in an error variant #738

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions testcontainers/src/core/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use url::Url;

use crate::core::{
client::exec::ExecResult,
copy::{CopyToContaienrError, CopyToContainer},
copy::{CopyToContainer, CopyToContainerError},
env,
env::ConfigurationError,
logs::{
Expand Down Expand Up @@ -91,7 +91,7 @@ pub enum ClientError {
#[error("failed to upload data to container: {0}")]
UploadToContainerError(BollardError),
#[error("failed to prepare data for copy-to-container: {0}")]
CopyToContaienrError(CopyToContaienrError),
CopyToContainerError(CopyToContainerError),
}

/// The internal client.
Expand Down Expand Up @@ -302,7 +302,7 @@ impl Client {
let tar = copy_to_container
.tar()
.await
.map_err(ClientError::CopyToContaienrError)?;
.map_err(ClientError::CopyToContainerError)?;

self.bollard
.upload_to_container::<String>(&container_id, Some(options), tar)
Expand Down
28 changes: 14 additions & 14 deletions testcontainers/src/core/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum CopyDataSource {
}

#[derive(Debug, thiserror::Error)]
pub enum CopyToContaienrError {
pub enum CopyToContainerError {
#[error("io failed with error: {0}")]
IoError(io::Error),
#[error("failed to get the path name: {0}")]
Expand All @@ -31,7 +31,7 @@ impl CopyToContainer {
}
}

pub(crate) async fn tar(&self) -> Result<bytes::Bytes, CopyToContaienrError> {
pub(crate) async fn tar(&self) -> Result<bytes::Bytes, CopyToContainerError> {
self.source.tar(&self.target).await
}
}
Expand All @@ -56,7 +56,7 @@ impl CopyDataSource {
pub(crate) async fn tar(
&self,
target_path: impl Into<String>,
) -> Result<bytes::Bytes, CopyToContaienrError> {
) -> Result<bytes::Bytes, CopyToContainerError> {
let target_path: String = target_path.into();

let bytes = match self {
Expand All @@ -73,37 +73,37 @@ impl CopyDataSource {
async fn tar_file(
source_file_path: &Path,
target_path: &str,
) -> Result<Vec<u8>, CopyToContaienrError> {
let target_path = make_path_relative(&target_path);
) -> Result<Vec<u8>, CopyToContainerError> {
let target_path = make_path_relative(target_path);
let meta = tokio::fs::metadata(source_file_path)
.await
.map_err(CopyToContaienrError::IoError)?;
.map_err(CopyToContainerError::IoError)?;

let mut ar = tokio_tar::Builder::new(Vec::new());
if meta.is_dir() {
ar.append_dir_all(target_path, source_file_path)
.await
.map_err(CopyToContaienrError::IoError)?;
.map_err(CopyToContainerError::IoError)?;
} else {
let f = &mut tokio::fs::File::open(source_file_path)
.await
.map_err(CopyToContaienrError::IoError)?;
.map_err(CopyToContainerError::IoError)?;

ar.append_file(target_path, f)
.await
.map_err(CopyToContaienrError::IoError)?;
.map_err(CopyToContainerError::IoError)?;
};

let res = ar
.into_inner()
.await
.map_err(CopyToContaienrError::IoError)?;
.map_err(CopyToContainerError::IoError)?;

Ok(res)
}

async fn tar_bytes(data: &Vec<u8>, target_path: &str) -> Result<Vec<u8>, CopyToContaienrError> {
let relative_target_path = make_path_relative(&target_path);
async fn tar_bytes(data: &Vec<u8>, target_path: &str) -> Result<Vec<u8>, CopyToContainerError> {
let relative_target_path = make_path_relative(target_path);

let mut header = tokio_tar::Header::new_gnu();
header.set_size(data.len() as u64);
Expand All @@ -113,12 +113,12 @@ async fn tar_bytes(data: &Vec<u8>, target_path: &str) -> Result<Vec<u8>, CopyToC
let mut ar = tokio_tar::Builder::new(Vec::new());
ar.append_data(&mut header, relative_target_path, data.as_slice())
.await
.map_err(CopyToContaienrError::IoError)?;
.map_err(CopyToContainerError::IoError)?;

let res = ar
.into_inner()
.await
.map_err(CopyToContaienrError::IoError)?;
.map_err(CopyToContainerError::IoError)?;

Ok(res)
}
Expand Down
2 changes: 1 addition & 1 deletion testcontainers/src/core/logs/consumer/logging_consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl LoggingConsumer {

fn format_message<'a>(&self, message: &'a str) -> Cow<'a, str> {
// Remove trailing newlines
let message = message.trim_end_matches(|c| c == '\n' || c == '\r');
let message = message.trim_end_matches(['\n', '\r']);

if let Some(prefix) = &self.prefix {
Cow::Owned(format!("{} {}", prefix, message))
Expand Down
2 changes: 1 addition & 1 deletion testcontainers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub mod core;
#[cfg_attr(docsrs, doc(cfg(feature = "blocking")))]
pub use crate::core::Container;
pub use crate::core::{
copy::{CopyDataSource, CopyToContaienrError, CopyToContainer},
copy::{CopyDataSource, CopyToContainer, CopyToContainerError},
error::TestcontainersError,
ContainerAsync, ContainerRequest, Image, ImageExt,
};
Expand Down
4 changes: 2 additions & 2 deletions testimages/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() -> Result<()> {
let output = Command::new("docker")
.arg("build")
.arg("--file")
.arg(&format!("{cwd}/src/dockerfiles/no_expose_port.dockerfile"))
.arg(format!("{cwd}/src/dockerfiles/no_expose_port.dockerfile"))
.arg("--force-rm")
.arg("--tag")
.arg("no_expose_port:latest")
Expand All @@ -24,7 +24,7 @@ fn main() -> Result<()> {
let output = Command::new("docker")
.arg("build")
.arg("--file")
.arg(&format!(
.arg(format!(
"{cwd}/src/dockerfiles/simple_web_server.dockerfile"
))
.arg("--force-rm")
Expand Down
Loading