Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
qaul.net
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
21
Issues
21
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qaul.net – قول
qaul.net
Commits
c272f812
Commit
c272f812
authored
Aug 07, 2019
by
jess 3jane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added unit tests to method gaurd
parent
6fcae840
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
libqaul/http-api/src/method.rs
libqaul/http-api/src/method.rs
+64
-0
No files found.
libqaul/http-api/src/method.rs
View file @
c272f812
...
...
@@ -146,3 +146,67 @@ impl BeforeMiddleware for MethodGaurd {
}
}
}
#[cfg(test)]
mod
test
{
use
anneal
::
RequestBuilder
;
use
super
::
*
;
#[test]
fn
same_method
()
{
let
gaurds
=
[
(
MethodGaurd
::
new
(
vec!
[
Method
::
Get
,
Method
::
Extension
(
"a"
.into
())]),
Method
::
Extension
(
"a"
.into
()),
),
(
MethodGaurd
::
new
(
vec!
[
Method
::
Get
,
Method
::
Extension
(
"a"
.into
())]),
Method
::
Get
,
),
(
MethodGaurd
::
options
(),
Method
::
Options
),
(
MethodGaurd
::
get
(),
Method
::
Get
),
(
MethodGaurd
::
post
(),
Method
::
Post
),
(
MethodGaurd
::
put
(),
Method
::
Put
),
(
MethodGaurd
::
delete
(),
Method
::
Delete
),
(
MethodGaurd
::
head
(),
Method
::
Head
),
(
MethodGaurd
::
trace
(),
Method
::
Trace
),
(
MethodGaurd
::
connect
(),
Method
::
Connect
),
(
MethodGaurd
::
patch
(),
Method
::
Patch
),
];
for
(
gaurd
,
method
)
in
gaurds
.iter
()
{
RequestBuilder
::
new
(
method
.clone
(),
"http://127.0.0.1:8080/"
)
.request
(|
mut
req
|
{
gaurd
.before
(
&
mut
req
)
.unwrap
();
});
}
}
#[test]
fn
different_method
()
{
let
gaurds
=
[
(
MethodGaurd
::
new
(
vec!
[
Method
::
Get
,
Method
::
Extension
(
"a"
.into
())]),
Method
::
Options
,
),
(
MethodGaurd
::
options
(),
Method
::
Get
),
(
MethodGaurd
::
get
(),
Method
::
Post
),
(
MethodGaurd
::
post
(),
Method
::
Put
),
(
MethodGaurd
::
put
(),
Method
::
Delete
),
(
MethodGaurd
::
delete
(),
Method
::
Head
),
(
MethodGaurd
::
head
(),
Method
::
Trace
),
(
MethodGaurd
::
trace
(),
Method
::
Connect
),
(
MethodGaurd
::
connect
(),
Method
::
Patch
),
(
MethodGaurd
::
patch
(),
Method
::
Extension
(
"a"
.into
())),
];
for
(
gaurd
,
method
)
in
gaurds
.iter
()
{
RequestBuilder
::
new
(
method
.clone
(),
"http://127.0.0.1:8080/"
)
.request
(|
mut
req
|
{
if
let
Ok
(
_
)
=
gaurd
.before
(
&
mut
req
)
{
panic!
(
"Request was successful"
);
}
});
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment