Skip to content

Commit

Permalink
feat: add ui test for filtering singular queries in smart contracts
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Strygin <[email protected]>
  • Loading branch information
DCNick3 committed May 23, 2024
1 parent ebca83b commit 8260697
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions smart_contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ webassembly-test = "0.1.0"
# Not used directly but required for compilation
getrandom = { version = "0.2", features = ["custom"] }

trybuild = { workspace = true }
9 changes: 9 additions & 0 deletions smart_contract/tests/ui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![cfg(not(coverage))]
use trybuild::TestCases;

#[cfg(not(target_arch = "wasm32"))]
#[test]
fn ui() {
let test_cases = TestCases::new();
test_cases.compile_fail("tests/ui_fail/*.rs");
}
12 changes: 12 additions & 0 deletions smart_contract/tests/ui_fail/cant_filter_singular_query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use iroha_smart_contract::{
data_model::query::predicate::{string::StringPredicate, value::QueryOutputPredicate},
prelude::*,
};

fn main() {
FindPermissionSchema
.filter(QueryOutputPredicate::Identifiable(
StringPredicate::starts_with("xor_"),
))
.execute()
}
25 changes: 25 additions & 0 deletions smart_contract/tests/ui_fail/cant_filter_singular_query.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error[E0599]: the method `filter` exists for struct `FindPermissionSchema`, but its trait bounds were not satisfied
--> tests/ui_fail/cant_filter_singular_query.rs:8:10
|
7 | / FindPermissionSchema
8 | | .filter(QueryOutputPredicate::Identifiable(
| | -^^^^^^ method cannot be called on `FindPermissionSchema` due to unsatisfied trait bounds
| |_________|
|
|
::: $WORKSPACE/data_model/src/query/mod.rs
|
| / queries! {
| | /// Finds all registered permission tokens
| | #[derive(Copy, Display)]
| | #[ffi_type]
... |
| | }
| | }
| |_____- doesn't satisfy `_: ExecuteIterableQueryOnHost`, `_: IterableQuery` or `_: Iterator`
|
= note: the following trait bounds were not satisfied:
`iroha_smart_contract::prelude::FindPermissionSchema: IterableQuery`
which is required by `iroha_smart_contract::prelude::FindPermissionSchema: iroha_smart_contract::ExecuteIterableQueryOnHost`
`iroha_smart_contract::prelude::FindPermissionSchema: Iterator`
which is required by `&mut iroha_smart_contract::prelude::FindPermissionSchema: Iterator`

0 comments on commit 8260697

Please sign in to comment.