1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#[allow(unused_imports)]
use feignhttp::{get, post, Result};
#[test]
fn test_validate_no_url () {
// error: no metadata assign
// | #[get]
// | ^^^^^^^^
// #[get]
// pub fn get() {}
}
#[test]
fn test_validate_url() {
// error: metadata url not specified
// | #[get(aaa = "http://xxx")]
// | ^^^^^^^^^^^^^^^^^^^^^^^^^^
// #[get(aaa = "http://xxx")]
// pub fn get() {}
}
#[test]
fn test_validate_url2() {
// error: metadata url not specified
// | #[get(path = "/xxx")]
// | ^^^^^^^^^^^^^^^^^^^^^
// #[get(path = "/xxx")]
// pub fn get() {}
}
#[test]
fn test_validate_invalid_url() {
// error: metadata url is invalid
// | #[get(url + "/aaa")]
// | ^^^^^^^^^^^^^^^^^^^^
// let url = "http://xxx";
// #[get(url + "/aaa")]
// pub fn get() {}
}
#[test]
fn test_validate_async () {
// error: only support async fn
// | pub fn get() {}
// | ^^
// #[get("http://xxx")]
// pub fn get() {}
}
#[test]
fn test_validate_return_value() {
// error: function must have a return value
// | pub async fn get() {}
// | ^^^^^^^^^^^^^^
// #[get("http://xxx")]
// pub async fn get() {}
}
#[test]
fn test_validate_return_value2() {
// error: return value must be Result
// | pub async fn get() -> i32 {}
// | ^^^^^^^^^^^^^^^^^^^^^
// #[get("http://xxx")]
// pub async fn get() -> i32 {}
}
#[test]
fn test_validate_arg() {
// error: unknown content marker: aaa
// | pub async fn get(#[aaa] a: i32) -> Result<String> {}
// | ^^^
// #[get("http://xxx")]
// pub async fn get(#[aaa] a: i32) -> Result<String> {}
}
#[test]
fn test_validate_arg2() {
// error: unknown content marker: bbb
// | pub async fn get(a: i32, #[bbb] b: i32) -> Result<String> {}
// | ^^^
// #[get("http://xxx")]
// pub async fn get(a: i32, #[bbb] b: i32) -> Result<String> {}
}
#[test]
fn test_validate_form() {
// error: one form parameter only supports scalar types, &str, String or struct
// | pub async fn get(#[form] s: &String) -> Result<String> {}
// | ^^^^^^^^^^
// #[post("http://xxx")]
// pub async fn get(#[form] s: &String) -> Result<String> {}
}
#[test]
fn test_validate_form2() {
// error: two or more form parameters only supports scalar types, &str or String
// | pub async fn get(#[form] a: i32, #[form] b: &i32, #[form] f: F) -> Result<String> {}
// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// struct F;
// #[post("http://xxx")]
// pub async fn get(#[form] a: i32, #[form] b: &i32, #[form] f: F) -> Result<String> {}
}
#[test]
fn test_validate_body() {
// error: request must have only one body
// | pub async fn get(#[body] b: B, #[body] b2: B) -> Result<String> {}
// | ^^^^^^^^^^^^^^^^^^^
// struct B;
// #[post("http://xxx")]
// pub async fn get(#[body] b: B, #[body] b2: B) -> Result<String> {}
}
#[test]
fn test_validate_body_form() {
// error: request must have only one of body or form
// | pub async fn get(#[body] b: S, #[form] f: S) -> Result<String> {}
// | ^^^^^^^^^^^^^^^^^^
// struct S;
// #[post("http://xxx")]
// pub async fn get(#[body] b: S, #[form] f: S) -> Result<String> {}
}