Skip to content

Commit

Permalink
refactored tests into 24 separate tests (#118)
Browse files Browse the repository at this point in the history
* cleanup remove_bucket_helper

* update TextContext creation

* update tests
  • Loading branch information
HJLebbink authored Feb 28, 2025
1 parent cba673a commit c4e302d
Show file tree
Hide file tree
Showing 4 changed files with 1,234 additions and 1,201 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ xmltree = "0.11.0"

[dev-dependencies]
async-std = { version = "1.13.0", features = ["attributes", "tokio1"] }
clap = { version = "4.5.23", features = ["derive"] }
clap = { version = "4.5.27", features = ["derive"] }
quickcheck = "1.0.3"

[[example]]
Expand Down
38 changes: 19 additions & 19 deletions src/s3/builders/put_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::s3::{
use super::{ObjectContent, SegmentedBytes};

/// Argument for
/// [create_multipart_upload()](crate::s3::client::Client::create_multipart_upload)
/// [create_multipart_upload()](Client::create_multipart_upload)
/// API
#[derive(Clone, Debug, Default)]
pub struct CreateMultipartUpload {
Expand Down Expand Up @@ -170,7 +170,7 @@ impl S3Api for CreateMultipartUpload {
}

/// Argument for
/// [abort_multipart_upload()](crate::s3::client::Client::abort_multipart_upload)
/// [abort_multipart_upload()](Client::abort_multipart_upload)
/// API
#[derive(Clone, Debug, Default)]
pub struct AbortMultipartUpload {
Expand Down Expand Up @@ -252,7 +252,7 @@ impl S3Api for AbortMultipartUpload {
}

/// Argument for
/// [complete_multipart_upload()](crate::s3::client::Client::complete_multipart_upload)
/// [complete_multipart_upload()](Client::complete_multipart_upload)
/// API
#[derive(Clone, Debug, Default)]
pub struct CompleteMultipartUpload {
Expand Down Expand Up @@ -368,7 +368,7 @@ impl S3Api for CompleteMultipartUpload {
type S3Response = CompleteMultipartUploadResponse2;
}

/// Argument for [upload_part()](crate::s3::client::Client::upload_part) S3 API
/// Argument for [upload_part()](Client::upload_part) S3 API
#[derive(Debug, Clone, Default)]
pub struct UploadPart {
client: Option<Client>,
Expand Down Expand Up @@ -1126,23 +1126,23 @@ mod tests {
// Validate that basic invalid sizes return the expected error.
if let Size::Known(v) = part_size {
if v < MIN_PART_SIZE {
match res {
Err(Error::InvalidMinPartSize(v_err)) => return v == v_err,
_ => return false,
return match res {
Err(Error::InvalidMinPartSize(v_err)) => v == v_err,
_ => false,
}
}
if v > MAX_PART_SIZE {
match res {
Err(Error::InvalidMaxPartSize(v_err)) => return v == v_err,
_ => return false,
return match res {
Err(Error::InvalidMaxPartSize(v_err)) => v == v_err,
_ => false,
}
}
}
if let Size::Known(v) = object_size {
if v > MAX_OBJECT_SIZE {
match res {
Err(Error::InvalidObjectSize(v_err)) => return v == v_err,
_ => return false,
return match res {
Err(Error::InvalidObjectSize(v_err)) => v == v_err,
_ => false,
}
}
}
Expand All @@ -1167,23 +1167,23 @@ mod tests {
if psize > object_size {
return false;
}
part_count > 0 && part_count <= MAX_MULTIPART_COUNT
(part_count > 0) && (part_count <= MAX_MULTIPART_COUNT)
}
(Size::Known(_), Size::Unknown, _) => false,

(Size::Known(object_size), Size::Known(part_size), res) => {
if part_size > object_size || (part_size * (MAX_MULTIPART_COUNT as u64)) < object_size {
match res {
if (part_size > object_size) || ((part_size * (MAX_MULTIPART_COUNT as u64)) < object_size) {
return match res {
Err(Error::InvalidPartCount(v1, v2, v3)) => {
return v1 == object_size && v2 == part_size && v3 == MAX_MULTIPART_COUNT;
(v1 == object_size) && (v2 == part_size) && (v3 == MAX_MULTIPART_COUNT)
}
_ => return false,
_ => false,
}
}
match res {
Ok((psize, part_count)) => {
let expected_part_count = (object_size as f64 / part_size as f64).ceil() as u16;
return psize == part_size && part_count == Some(expected_part_count);
(psize == part_size) && (part_count == Some(expected_part_count))
}
_ => false,
}
Expand Down
11 changes: 11 additions & 0 deletions tests/run-tests-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Set environment variables to run tests on play.min.io
$Env:SERVER_ENDPOINT = "http://localhost:9000/"
$Env:ACCESS_KEY = "minioadmin"
$Env:SECRET_KEY = "minioadmin"
$Env:ENABLE_HTTPS = "false"
$Env:SSL_CERT_FILE = "./tests/public.crt"
$Env:IGNORE_CERT_CHECK = "false"
$Env:SERVER_REGION = ""

# Run tests
cargo test
Loading

0 comments on commit c4e302d

Please sign in to comment.