Make public Setup interface async
This commit is contained in:
parent
2d3e3688fa
commit
d173198729
3 changed files with 50 additions and 57 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use async_trait::async_trait;
|
||||
use schematics::async_utils::sleep;
|
||||
use schematics::async_utils::{run, sleep};
|
||||
use schematics::loggers::{Logger, StoringLogger};
|
||||
use schematics::resources::{AcmeUser, Cert, Csr, GitCheckout};
|
||||
use schematics::symbols::Symbol;
|
||||
|
|
@ -37,31 +37,33 @@ fn can_create_an_acme_user() {
|
|||
count: Rc::clone(&count),
|
||||
};
|
||||
let setup = Setup::new(runner, StoringLogger::new());
|
||||
assert_eq!((setup.add(AcmeUser).unwrap().0).0, "acme");
|
||||
assert_eq!((run(setup.add(AcmeUser)).unwrap().0).0, "acme");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runs_only_once() {
|
||||
let count = Rc::new(RefCell::new(0));
|
||||
let runner = TestSymbolRunner {
|
||||
count: Rc::clone(&count),
|
||||
};
|
||||
let setup = Setup::new(runner, StoringLogger::new());
|
||||
assert_eq!(
|
||||
(setup.add(Csr("somehost")).unwrap().0)
|
||||
.as_ref()
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"/etc/ssl/local_certs/somehost.csr",
|
||||
);
|
||||
assert_eq!(
|
||||
(setup.add(Csr("somehost")).unwrap().0)
|
||||
.as_ref()
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"/etc/ssl/local_certs/somehost.csr",
|
||||
);
|
||||
assert_eq!(*count.borrow(), 2 + 5); // Key and CSR + 5 dirs
|
||||
run(async {
|
||||
let count = Rc::new(RefCell::new(0));
|
||||
let runner = TestSymbolRunner {
|
||||
count: Rc::clone(&count),
|
||||
};
|
||||
let setup = Setup::new(runner, StoringLogger::new());
|
||||
assert_eq!(
|
||||
(setup.add(Csr("somehost")).await.unwrap().0)
|
||||
.as_ref()
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"/etc/ssl/local_certs/somehost.csr",
|
||||
);
|
||||
assert_eq!(
|
||||
(setup.add(Csr("somehost")).await.unwrap().0)
|
||||
.as_ref()
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"/etc/ssl/local_certs/somehost.csr",
|
||||
);
|
||||
assert_eq!(*count.borrow(), 2 + 5); // Key and CSR + 5 dirs
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -72,7 +74,7 @@ fn can_create_an_acme_cert() {
|
|||
};
|
||||
let setup = Setup::new(runner, StoringLogger::new());
|
||||
assert_eq!(
|
||||
(setup.add(Cert("somehost")).unwrap().0)
|
||||
(run(setup.add(Cert("somehost"))).unwrap().0)
|
||||
.as_ref()
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
|
|
@ -88,12 +90,11 @@ fn can_create_a_git_checkout() {
|
|||
count: Rc::clone(&count),
|
||||
};
|
||||
let setup = Setup::new(runner, StoringLogger::new());
|
||||
setup
|
||||
.add(GitCheckout(
|
||||
"/tmp/somepath".into(),
|
||||
"/tmp/some_src_repo",
|
||||
"master",
|
||||
))
|
||||
.unwrap();
|
||||
run(setup.add(GitCheckout(
|
||||
"/tmp/somepath".into(),
|
||||
"/tmp/some_src_repo",
|
||||
"master",
|
||||
)))
|
||||
.unwrap();
|
||||
assert_eq!(*count.borrow(), 3);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue