Skip to main content

toasty_driver_integration_suite/scenarios/
account_optional_contact_status.rs

1use crate::prelude::*;
2
3scenario! {
4    #[derive(Debug, toasty::Model)]
5    #[allow(dead_code)]
6    struct Account {
7        #[key]
8        id: String,
9
10        // Data-carrying enum.
11        contact: Option<Contact>,
12
13        // Unit-only enum.
14        status: Option<Status>,
15    }
16
17    #[derive(Debug, PartialEq, toasty::Embed)]
18    enum Contact {
19        #[column(variant = 1)]
20        Email { address: String },
21        #[column(variant = 2)]
22        Phone { number: String },
23    }
24
25    #[derive(Debug, PartialEq, toasty::Embed)]
26    enum Status {
27        #[column(variant = 1)]
28        Active,
29        #[column(variant = 2)]
30        Inactive,
31    }
32
33    async fn setup(test: &mut Test) -> toasty::Db {
34        test.setup_db(models!(Account)).await
35    }
36}