aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-02-09 17:43:07 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-03-07 17:32:02 +0100
commitcfea1e0315a2e2ad72ce05dffb44ed355e880e46 (patch)
tree6fa7d186284364b7d6778140ef02a9ce54ac2f1b
parent05eb79929eb0b5f2f2ecb1e3e4a21007c0e83a42 (diff)
downloadgarage-cfea1e0315a2e2ad72ce05dffb44ed355e880e46.tar.gz
garage-cfea1e0315a2e2ad72ce05dffb44ed355e880e46.zip
Functional tests for bucket endpoints
-rw-r--r--src/garage/tests/bucket.rs77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/garage/tests/bucket.rs b/src/garage/tests/bucket.rs
index 8b137891..2c3af542 100644
--- a/src/garage/tests/bucket.rs
+++ b/src/garage/tests/bucket.rs
@@ -1 +1,78 @@
+use crate::common;
+use aws_sdk_s3::model::BucketLocationConstraint;
+use aws_sdk_s3::output::DeleteBucketOutput;
+#[tokio::test]
+async fn test_bucket_all() {
+ let ctx = common::context();
+ let bucket_name = "hello";
+
+ {
+ // Create bucket
+ //@TODO check with an invalid bucket name + with an already existing bucket
+ let r = ctx
+ .client
+ .create_bucket()
+ .bucket(bucket_name)
+ .send()
+ .await
+ .unwrap();
+
+ assert_eq!(r.location.unwrap(), "/hello");
+ }
+ {
+ // List buckets
+ let r = ctx.client.list_buckets().send().await.unwrap();
+
+ assert_eq!(r.buckets.as_ref().unwrap().len(), 1);
+ assert_eq!(
+ r.buckets.unwrap().first().unwrap().name.as_ref().unwrap(),
+ bucket_name
+ );
+ }
+ {
+ // Get its location
+ let r = ctx
+ .client
+ .get_bucket_location()
+ .bucket(bucket_name)
+ .send()
+ .await
+ .unwrap();
+
+ match r.location_constraint.unwrap() {
+ BucketLocationConstraint::Unknown(v) if v.as_str() == "garage-integ-test" => (),
+ _ => unreachable!("wrong region"),
+ }
+ }
+ {
+ // (Stub) check GetVersioning
+ let r = ctx
+ .client
+ .get_bucket_versioning()
+ .bucket(bucket_name)
+ .send()
+ .await
+ .unwrap();
+
+ assert!(r.status.is_none());
+ }
+ {
+ // Delete bucket
+ // @TODO add a check with a non-empty bucket and check failure
+ let r = ctx
+ .client
+ .delete_bucket()
+ .bucket(bucket_name)
+ .send()
+ .await
+ .unwrap();
+
+ assert_eq!(r, DeleteBucketOutput::builder().build());
+ }
+ {
+ // Check bucket is deleted with List buckets
+ let r = ctx.client.list_buckets().send().await.unwrap();
+ assert_eq!(r.buckets.as_ref().unwrap().len(), 0);
+ }
+}