Skip to content

Commit 9a162b6

Browse files
committed
improve
1 parent 303f581 commit 9a162b6

13 files changed

+63
-173
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

butane/tests/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ path = "common/mod.rs"
2828

2929
[dependencies]
3030
butane = { workspace = true }
31+
butane_codegen.workspace = true
3132
butane_core = { workspace = true }
3233
butane_test_helper = { workspace = true, default-features = false, features = ["pg", "sqlite", "turso"] }
3334
butane_test_macros = { workspace = true }
@@ -52,6 +53,7 @@ sqlparser = { workspace = true }
5253
tokio = { workspace = true, features = ["macros"] }
5354
tokio-postgres = { features = ["with-geo-types-0_7"], workspace = true }
5455
tokio-test = { workspace = true }
56+
trybuild = "1.0"
5557
uuid_for_test = { package = "uuid", version = "1.2", features = ["v4"] }
5658

5759
[[test]]

butane/tests/trybuild.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#[test]
44
fn compile_tests() {
55
let t = trybuild::TestCases::new();
6-
t.pass("tests/trybuild/pass/*.rs");
7-
t.compile_fail("tests/trybuild/fail/*.rs");
6+
t.pass("trybuild/pass/*.rs");
7+
t.compile_fail("trybuild/fail/*.rs");
88
}

butane/tests/trybuild/fail/complex_enum_without_json.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

butane/tests/trybuild/fail/complex_enum_without_json.stderr

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use butane::filter;
2+
use butane_codegen::model;
3+
4+
#[model]
5+
struct Post {
6+
id: i64,
7+
title: String,
8+
}
9+
10+
fn main() {
11+
// This should fail - like expects a string literal, not a binary expression
12+
let _f = filter!(Post, title.like(1 + 2));
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: Unexpected binary expression as parameter to like
2+
--> trybuild/fail/filter_like_invalid_param.rs:12:14
3+
|
4+
12 | let _f = filter!(Post, title.like(1 + 2));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: this error originates in the macro `filter` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error[E0046]: not all trait items implemented, missing: `save_many_to_many_async`
10+
--> trybuild/fail/filter_like_invalid_param.rs:4:1
11+
|
12+
4 | #[model]
13+
| ^^^^^^^^ missing `save_many_to_many_async` in implementation
14+
|
15+
= note: this error originates in the attribute macro `model` (in Nightly builds, run with -Z macro-backtrace for more info)
16+
= help: implement the missing item: `async fn save_many_to_many_async(&mut self, _: &impl ConnectionMethodsAsync) -> Result<(), butane::Error> { todo!() }`
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use butane::filter;
2+
use butane_codegen::model;
3+
4+
#[model]
5+
struct Post {
6+
id: i64,
7+
title: String,
8+
}
9+
10+
fn main() {
11+
// This should fail - unsupported binary operator
12+
let _f = filter!(Post, title ^ "test");
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: Unsupported binary operator
2+
--> trybuild/fail/filter_unsupported_operator.rs:12:14
3+
|
4+
12 | let _f = filter!(Post, title ^ "test");
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: this error originates in the macro `filter` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error[E0046]: not all trait items implemented, missing: `save_many_to_many_async`
10+
--> trybuild/fail/filter_unsupported_operator.rs:4:1
11+
|
12+
4 | #[model]
13+
| ^^^^^^^^ missing `save_many_to_many_async` in implementation
14+
|
15+
= note: this error originates in the attribute macro `model` (in Nightly builds, run with -Z macro-backtrace for more info)
16+
= help: implement the missing item: `async fn save_many_to_many_async(&mut self, _: &impl ConnectionMethodsAsync) -> Result<(), butane::Error> { todo!() }`

butane/tests/trybuild/fail/struct_without_json_feature.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)