FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
expresscpp/test/serve_favicon.cpp at master · expresscpp/expresscpp · GitHub
expresscpp
/
expresscpp
Public
Notifications
You must be signed in to change notification settings
Fork
15
Star
96
Code
Issues
5
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
expresscpp
/
test
/
serve_favicon.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (26 loc) · 910 Bytes
Breadcrumbs
expresscpp
/
test
/
serve_favicon.cpp
Copy path
File metadata and controls
35 lines (26 loc) · 910 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
"
expresscpp/console.hpp
"
#
include
"
expresscpp/expresscpp.hpp
"
#
include
"
expresscpp/fetch.hpp
"
#
include
"
expresscpp/middleware/serve_favicon_provider.hpp
"
#
include
"
gtest/gtest.h
"
using
namespace
expresscpp
;
constexpr
uint16_t
port =
8081u
;
TEST
(FaviconTests, ServeFavicon) {
ExpressCpp app;
Console::setLogLevel
(LogLevel::
kDebug
);
FaviconProvider favicon_provider;
app.
Use
(favicon_provider);
app.
Use
([](
auto
/*
req
*/
,
auto
res,
auto
/*
next
*/
) {
if
(!res->
ResponseSent
()) {
res->
Send
(
"
resource not found
"
);
}
});
//
start listening for requests and block until ctrl+C
app.
Listen
(port, [=](
auto
ec) {
EXPECT_FALSE
(ec);
const
auto
get_response =
fetch
(
fmt::format
(
"
localhost:{}/favicon.ico
"
, port));
auto
expected_size = favicon_provider.
GetFavicon
().
size
();
auto
actual_size = get_response.
size
();
EXPECT_EQ
(expected_size, actual_size);
});
}
Back
|
FazBrowse Home
|
New Git URL