-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add compilation tests related to recent changes
- Loading branch information
glendc
committed
Apr 5, 2024
1 parent
77f9ff6
commit 10d9ce1
Showing
11 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
venndb-usage/tests/compiles/derive_struct_all_the_things.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use venndb::VennDB; | ||
|
||
#[derive(Debug, VennDB)] | ||
#[venndb(name = "EmployeeSheet")] | ||
struct Employee { | ||
#[venndb(key)] | ||
id: u32, | ||
name: String, | ||
is_manager: bool, | ||
is_admin: bool, | ||
#[venndb(skip)] | ||
is_active: bool, | ||
department: Department, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum Department { | ||
Engineering, | ||
Sales, | ||
Marketing, | ||
HR, | ||
} | ||
|
||
fn main() { | ||
let mut db = EmployeeSheet::new(); | ||
db.append(Employee { | ||
id: 1, | ||
name: "Alice".to_string(), | ||
is_manager: true, | ||
is_admin: false, | ||
is_active: true, | ||
department: Department::Engineering, | ||
}); | ||
|
||
let employee_ref = db.get_by_id(&1).unwrap(); | ||
assert_eq!(employee_ref.id, 1); | ||
assert_eq!(employee_ref.name, "Alice"); | ||
|
||
let mut query = db.query(); | ||
query.is_manager(true).is_admin(true); | ||
assert!(query.execute().is_none()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use venndb::VennDB; | ||
|
||
#[derive(Debug, VennDB)] | ||
struct Employee {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use venndb::VennDB; | ||
|
||
#[derive(Debug, VennDB)] | ||
struct Employee { | ||
#[venndb(skip)] | ||
id: u32, | ||
#[venndb(skip)] | ||
name: String, | ||
#[venndb(skip)] | ||
is_manager: bool, | ||
#[venndb(skip)] | ||
department: Department, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum Department { | ||
Engineering, | ||
Sales, | ||
Marketing, | ||
HR, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use venndb::VennDB; | ||
|
||
#[derive(Debug, VennDB)] | ||
struct Employee { | ||
id: u32, | ||
is_manager: bool, | ||
#[venndb(skip)] | ||
is_active: bool, | ||
} | ||
|
||
fn main() { | ||
let mut db = EmployeeDB::new(); | ||
db.append(Employee { | ||
id: 1, | ||
is_manager: true, | ||
is_active: true, | ||
}); | ||
|
||
let mut query = db.query(); | ||
query.is_active(true); | ||
assert!(query.execute().is_some()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error[E0599]: no method named `is_active` found for struct `EmployeeDBQuery` in the current scope | ||
--> tests/fails/filter_skipped_field.rs:20:11 | ||
| | ||
3 | #[derive(Debug, VennDB)] | ||
| ------ method `is_active` not found for this struct | ||
... | ||
20 | query.is_active(true); | ||
| ^^^^^^^^^ method not found in `EmployeeDBQuery<'_>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use venndb::VennDB; | ||
|
||
#[derive(Debug, VennDB)] | ||
struct Employee { | ||
#[venndb(foo)] | ||
id: u32, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
error: Invalid field-level `venndb` attribute | ||
Expected one of: `key` | ||
--> tests/fails/unknown_attr_field.rs:5:14 | ||
| | ||
5 | #[venndb(foo)] | ||
| ^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use venndb::VennDB; | ||
|
||
#[derive(Debug, VennDB)] | ||
#[venndb(foo)] | ||
struct Employee { | ||
id: u32, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
error: Invalid field-level `venndb` attribute | ||
Expected one of: `name` | ||
--> tests/fails/unknown_attr_struct.rs:4:10 | ||
| | ||
4 | #[venndb(foo)] | ||
| ^^^ |