-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tests for raw request data and rustify_derive
- Loading branch information
Showing
18 changed files
with
283 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ env_logger = "0.9.0" | |
httpmock = "0.6.2" | ||
serde_with = "1.9.4" | ||
test-env-log = "0.2.7" | ||
trybuild = "1.0.45" |
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
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,5 @@ | ||
#[test] | ||
fn test_macro() { | ||
let t = trybuild::TestCases::new(); | ||
t.compile_fail("tests/macro/*.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,13 @@ | ||
use rustify::endpoint::Endpoint; | ||
use rustify_derive::Endpoint; | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, Endpoint, Serialize)] | ||
#[endpoint] | ||
struct Test {} | ||
|
||
#[derive(Debug, Endpoint, Serialize)] | ||
#[endpoint()] | ||
struct TestTwo {} | ||
|
||
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,19 @@ | ||
error: Cannot parse attribute as list | ||
--> $DIR/empty_attr.rs:6:3 | ||
| | ||
6 | #[endpoint] | ||
| ^^^^^^^^ | ||
|
||
error: Attribute cannot be empty | ||
--> $DIR/empty_attr.rs:10:3 | ||
| | ||
10 | #[endpoint()] | ||
| ^^^^^^^^ | ||
|
||
warning: unused import: `rustify::endpoint::Endpoint` | ||
--> $DIR/empty_attr.rs:1:5 | ||
| | ||
1 | use rustify::endpoint::Endpoint; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unused_imports)]` on by default |
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 rustify::endpoint::Endpoint; | ||
use rustify_derive::Endpoint; | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, Endpoint, Serialize)] | ||
#[endpoint(path = "test/path")] | ||
struct Test { | ||
pub name: String, | ||
#[endpoint(data)] | ||
pub data: String, | ||
} | ||
|
||
#[derive(Debug, Endpoint, Serialize)] | ||
#[endpoint(path = "test/path")] | ||
struct TestTwo { | ||
pub name: String, | ||
#[endpoint(data)] | ||
pub data: Vec<u8>, | ||
#[endpoint(data)] | ||
pub data_two: Vec<u8>, | ||
} | ||
|
||
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 @@ | ||
error: May only mark one field as the data field | ||
--> $DIR/invalid_data.rs:20:9 | ||
| | ||
20 | pub data_two: Vec<u8>, | ||
| ^^^^^^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/invalid_data.rs:5:17 | ||
| | ||
5 | #[derive(Debug, Endpoint, Serialize)] | ||
| ^^^^^^^^ expected slice `[u8]`, found struct `std::string::String` | ||
| | ||
= note: expected reference `&[u8]` | ||
found reference `&std::string::String` | ||
= note: this error originates in the derive macro `Endpoint` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
warning: unused import: `rustify::endpoint::Endpoint` | ||
--> $DIR/invalid_data.rs:1:5 | ||
| | ||
1 | use rustify::endpoint::Endpoint; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unused_imports)]` on by default |
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 rustify::endpoint::Endpoint; | ||
use rustify_derive::Endpoint; | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, Endpoint, Serialize)] | ||
#[endpoint(path = "test/path", method = "TEST")] | ||
struct Test {} | ||
|
||
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,13 @@ | ||
warning: unused import: `rustify::endpoint::Endpoint` | ||
--> $DIR/invalid_method.rs:1:5 | ||
| | ||
1 | use rustify::endpoint::Endpoint; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unused_imports)]` on by default | ||
|
||
error[E0599]: no variant or associated item named `TEST` found for enum `RequestMethod` in the current scope | ||
--> $DIR/invalid_method.rs:6:41 | ||
| | ||
6 | #[endpoint(path = "test/path", method = "TEST")] | ||
| ^^^^^^ variant or associated item not found in `RequestMethod` |
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 rustify::endpoint::Endpoint; | ||
use rustify_derive::Endpoint; | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, Endpoint, Serialize)] | ||
#[endpoint(path = "test/path", result = "DoesNotExist")] | ||
struct Test {} | ||
|
||
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,13 @@ | ||
error[E0412]: cannot find type `DoesNotExist` in this scope | ||
--> $DIR/invalid_result.rs:6:41 | ||
| | ||
6 | #[endpoint(path = "test/path", result = "DoesNotExist")] | ||
| ^^^^^^^^^^^^^^ not found in this scope | ||
|
||
warning: unused import: `rustify::endpoint::Endpoint` | ||
--> $DIR/invalid_result.rs:1:5 | ||
| | ||
1 | use rustify::endpoint::Endpoint; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unused_imports)]` on by default |
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 rustify::endpoint::Endpoint; | ||
use rustify_derive::Endpoint; | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, Endpoint, Serialize)] | ||
#[endpoint(path = "test/path", request_type = "BAD", response_type = "BAD")] | ||
struct Test {} | ||
|
||
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,19 @@ | ||
warning: unused import: `rustify::endpoint::Endpoint` | ||
--> $DIR/invalid_type.rs:1:5 | ||
| | ||
1 | use rustify::endpoint::Endpoint; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unused_imports)]` on by default | ||
|
||
error[E0599]: no variant or associated item named `BAD` found for enum `RequestType` in the current scope | ||
--> $DIR/invalid_type.rs:6:47 | ||
| | ||
6 | #[endpoint(path = "test/path", request_type = "BAD", response_type = "BAD")] | ||
| ^^^^^ variant or associated item not found in `RequestType` | ||
|
||
error[E0599]: no variant or associated item named `BAD` found for enum `ResponseType` in the current scope | ||
--> $DIR/invalid_type.rs:6:70 | ||
| | ||
6 | #[endpoint(path = "test/path", request_type = "BAD", response_type = "BAD")] | ||
| ^^^^^ variant or associated item not found in `ResponseType` |
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 @@ | ||
use rustify::endpoint::Endpoint; | ||
use rustify_derive::Endpoint; | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, Endpoint, Serialize)] | ||
struct Test {} | ||
|
||
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,15 @@ | ||
error: Deriving `Endpoint` requires attaching an `endpoint` attribute | ||
--> $DIR/no_attr.rs:5:17 | ||
| | ||
5 | #[derive(Debug, Endpoint, Serialize)] | ||
| ^^^^^^^^ | ||
| | ||
= note: this error originates in the derive macro `Endpoint` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
warning: unused import: `rustify::endpoint::Endpoint` | ||
--> $DIR/no_attr.rs:1:5 | ||
| | ||
1 | use rustify::endpoint::Endpoint; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unused_imports)]` on by default |
Oops, something went wrong.