aboutsummaryrefslogtreecommitdiff
path: root/src/garage/tests/common/mod.rs
diff options
context:
space:
mode:
authorJill <kokakiwi@deuxfleurs.fr>2022-02-04 17:55:54 +0100
committerJill <kokakiwi@deuxfleurs.fr>2022-02-10 17:55:50 +0100
commitd7decda3f4423602e2a8064fa398181736b3a3ab (patch)
treef8b8ee686989bc987e036d47a897864016c7656e /src/garage/tests/common/mod.rs
parentcd13ea461b5e6011ddda28c4923260315d67482a (diff)
downloadgarage-d7decda3f4423602e2a8064fa398181736b3a3ab.tar.gz
garage-d7decda3f4423602e2a8064fa398181736b3a3ab.zip
garage(tests): Add random suffix to created buckets.
Diffstat (limited to 'src/garage/tests/common/mod.rs')
-rw-r--r--src/garage/tests/common/mod.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/garage/tests/common/mod.rs b/src/garage/tests/common/mod.rs
index b5f7f0b2..c40fde0f 100644
--- a/src/garage/tests/common/mod.rs
+++ b/src/garage/tests/common/mod.rs
@@ -7,6 +7,7 @@ pub mod macros;
pub mod client;
pub mod ext;
pub mod garage;
+pub mod util;
const REGION: Region = Region::from_static("garage-integ-test");
@@ -23,20 +24,27 @@ impl Context {
Context { garage, client }
}
- pub fn create_bucket(&self, name: &str) {
+ /// Create an unique bucket with a random suffix.
+ ///
+ /// Return the created bucket full name.
+ pub fn create_bucket(&self, name: &str) -> String {
+ let bucket_name = format!("{}-{}", name, util::random_id(6));
+
self.garage
.command()
- .args(["bucket", "create", name])
+ .args(["bucket", "create", &bucket_name])
.quiet()
.expect_success_status("Could not create bucket");
self.garage
.command()
.args(["bucket", "allow"])
.args(["--owner", "--read", "--write"])
- .arg(name)
+ .arg(&bucket_name)
.args(["--key", &self.garage.key.name])
.quiet()
.expect_success_status("Could not allow key for bucket");
+
+ bucket_name
}
}