assay_core/
quarantine.rs

1use crate::storage::store::Store;
2
3#[derive(Debug, Clone, Copy)]
4pub enum QuarantineMode {
5    Off,
6    Warn,
7    Strict,
8}
9
10impl QuarantineMode {
11    pub fn parse(s: &str) -> Self {
12        match s {
13            "off" => Self::Off,
14            "strict" => Self::Strict,
15            _ => Self::Warn,
16        }
17    }
18}
19
20#[derive(Clone)]
21pub struct QuarantineService {
22    store: Store,
23}
24
25impl QuarantineService {
26    pub fn new(store: Store) -> Self {
27        Self { store }
28    }
29
30    pub fn is_quarantined(&self, suite: &str, test_id: &str) -> anyhow::Result<Option<String>> {
31        self.store.quarantine_get_reason(suite, test_id)
32    }
33
34    pub fn add(&self, suite: &str, test_id: &str, reason: &str) -> anyhow::Result<()> {
35        self.store.quarantine_add(suite, test_id, reason)
36    }
37
38    pub fn remove(&self, suite: &str, test_id: &str) -> anyhow::Result<()> {
39        self.store.quarantine_remove(suite, test_id)
40    }
41}