1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-04-20 06:54:46 +00:00

a whole bunch of tests for the method macros

This commit is contained in:
Dominic 2020-05-08 18:39:11 +02:00
parent 4bf0bd7b09
commit e05f9bb963
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
23 changed files with 473 additions and 28 deletions

View file

@ -0,0 +1,15 @@
#[macro_use] extern crate gotham_restful;
use gotham_restful::State;
#[derive(Resource)]
#[resource(read_all)]
struct FooResource;
#[read_all(FooResource)]
async fn read_all(state : &State)
{
}
fn main()
{
}

View file

@ -0,0 +1,21 @@
error: async fn must not take &State as an argument as State is not Sync, consider boxing
--> $DIR/method_async_state.rs:9:19
|
9 | async fn read_all(state : &State)
| ^^^^^
error[E0433]: failed to resolve: use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read_all`
--> $DIR/method_async_state.rs:4:10
|
4 | #[derive(Resource)]
| ^^^^^^^^ use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read_all`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
warning: unused import: `gotham_restful::State`
--> $DIR/method_async_state.rs:2:5
|
2 | use gotham_restful::State;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default

View file

@ -0,0 +1,10 @@
#[macro_use] extern crate gotham_restful;
#[read_all(UnknownResource)]
fn read_all()
{
}
fn main()
{
}

View file

@ -0,0 +1,5 @@
error[E0412]: cannot find type `UnknownResource` in this scope
--> $DIR/method_for_unknown_resource.rs:3:12
|
3 | #[read_all(UnknownResource)]
| ^^^^^^^^^^^^^^^ not found in this scope

View file

@ -0,0 +1,14 @@
#[macro_use] extern crate gotham_restful;
#[derive(Resource)]
#[resource(read_all)]
struct FooResource;
#[read_all]
fn read_all()
{
}
fn main()
{
}

View file

@ -0,0 +1,15 @@
error: Missing Resource struct. Example: #[read_all(MyResource)]
--> $DIR/method_no_resource.rs:7:1
|
7 | #[read_all]
| ^^^^^^^^^^^
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read_all`
--> $DIR/method_no_resource.rs:3:10
|
3 | #[derive(Resource)]
| ^^^^^^^^ use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read_all`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

14
tests/ui/method_self.rs Normal file
View file

@ -0,0 +1,14 @@
#[macro_use] extern crate gotham_restful;
#[derive(Resource)]
#[resource(read_all)]
struct FooResource;
#[read_all(FooResource)]
fn read_all(self)
{
}
fn main()
{
}

View file

@ -0,0 +1,13 @@
error: Didn't expect self parameter
--> $DIR/method_self.rs:8:13
|
8 | fn read_all(self)
| ^^^^
error[E0433]: failed to resolve: use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read_all`
--> $DIR/method_self.rs:3:10
|
3 | #[derive(Resource)]
| ^^^^^^^^ use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read_all`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

View file

@ -0,0 +1,14 @@
#[macro_use] extern crate gotham_restful;
#[derive(Resource)]
#[resource(read)]
struct FooResource;
#[read(FooResource)]
fn read()
{
}
fn main()
{
}

View file

@ -0,0 +1,13 @@
error: Too few arguments
--> $DIR/method_too_few_args.rs:8:4
|
8 | fn read()
| ^^^^
error[E0433]: failed to resolve: use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read`
--> $DIR/method_too_few_args.rs:3:10
|
3 | #[derive(Resource)]
| ^^^^^^^^ use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

View file

@ -0,0 +1,14 @@
#[macro_use] extern crate gotham_restful;
#[derive(Resource)]
#[resource(read_all)]
struct FooResource;
#[read_all(FooResource)]
fn read_all(_id : u64)
{
}
fn main()
{
}

View file

@ -0,0 +1,13 @@
error: Too many arguments
--> $DIR/method_too_many_args.rs:8:13
|
8 | fn read_all(_id : u64)
| ^^^
error[E0433]: failed to resolve: use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read_all`
--> $DIR/method_too_many_args.rs:3:10
|
3 | #[derive(Resource)]
| ^^^^^^^^ use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read_all`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

14
tests/ui/method_unsafe.rs Normal file
View file

@ -0,0 +1,14 @@
#[macro_use] extern crate gotham_restful;
#[derive(Resource)]
#[resource(read_all)]
struct FooResource;
#[read_all(FooResource)]
unsafe fn read_all()
{
}
fn main()
{
}

View file

@ -0,0 +1,13 @@
error: Resource methods must not be unsafe
--> $DIR/method_unsafe.rs:8:1
|
8 | unsafe fn read_all()
| ^^^^^^
error[E0433]: failed to resolve: use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read_all`
--> $DIR/method_unsafe.rs:3:10
|
3 | #[derive(Resource)]
| ^^^^^^^^ use of undeclared type or module `_gotham_restful_resource_foo_resource_method_read_all`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)