feat: fire and test deployment deletion event when deployment is deleted

This commit is contained in:
Aravinth Manivannan 2022-12-06 06:30:56 +05:30
parent 3594d4e23b
commit 538bc41113
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 8 additions and 3 deletions

View file

@ -90,7 +90,6 @@ impl Ctx {
if let Some(_config) = page_config::Config::load(&page.path, &page.branch) {
unimplemented!();
}
println!("{}", page.domain);
self.db
.log_event(&page.domain, &db::EVENT_TYPE_UPDATE)
.await
@ -103,8 +102,10 @@ impl Ctx {
if let Ok(db_site) = self.db.get_site_from_pub_id(site_id, owner).await {
let path = get_website_path(&self.settings, &db_site.hostname);
// TODO fire delete event, but must figure out way to erect tombstone. Events link to
// sites, so deleting site record isn't possible
self.db
.log_event(&db_site.hostname, &db::EVENT_TYPE_DELETE)
.await?;
fs::remove_dir_all(&path).await?;
self.db
.delete_site(&db_site.owner, &db_site.hostname)

View file

@ -221,6 +221,10 @@ mod tests {
Some(ServiceError::WebsiteNotFound)
);
let mut events = ctx.db.list_all_site_events(&site.hostname).await.unwrap();
let possible_delete = events.pop().unwrap();
assert_eq!(&possible_delete.event_type, &*crate::db::EVENT_TYPE_DELETE);
let _ = ctx.delete_user(NAME, PASSWORD).await;
}
}