aboutsummaryrefslogtreecommitdiff
path: root/src/garage/tests/common/mod.rs
blob: b5f7f0b2bbb84d8624bbcf75ff4f4141ddce1cb2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use aws_sdk_s3::{Client, Region};
use ext::*;

#[macro_use]
pub mod macros;

pub mod client;
pub mod ext;
pub mod garage;

const REGION: Region = Region::from_static("garage-integ-test");

pub struct Context {
	pub garage: &'static garage::Instance,
	pub client: Client,
}

impl Context {
	fn new() -> Self {
		let garage = garage::instance();
		let client = client::build_client(garage);

		Context { garage, client }
	}

	pub fn create_bucket(&self, name: &str) {
		self.garage
			.command()
			.args(["bucket", "create", name])
			.quiet()
			.expect_success_status("Could not create bucket");
		self.garage
			.command()
			.args(["bucket", "allow"])
			.args(["--owner", "--read", "--write"])
			.arg(name)
			.args(["--key", &self.garage.key.name])
			.quiet()
			.expect_success_status("Could not allow key for bucket");
	}
}

pub fn context() -> Context {
	Context::new()
}