@@ -22,8 +22,44 @@ TEST_CASE("Integration Tests")
22
22
23
23
CHECK (keys[" get" ] == " ok" );
24
24
}
25
+
26
+ SECTION (" GET request with single query parameter" )
27
+ {
28
+ SimpleHttp::HttpUrl &httpUrl = url
29
+ .with_path_segments (SimpleHttp::PathSegments{{SimpleHttp::PathSegment{" get_hello" }}})
30
+ .with_query_parameters (SimpleHttp::QueryParameters{
31
+ {{SimpleHttp::QueryParameterKey{" name" }, SimpleHttp::QueryParameterValue{" test" }}}
32
+ });
33
+ auto maybe_response = client.get (httpUrl);
34
+
35
+ REQUIRE (maybe_response);
36
+
37
+ SimpleHttp::HttpResponse response = maybe_response.value ();
38
+ auto keys = nlohmann::json::parse (response.body .value ());
39
+
40
+ CHECK (keys[" hello" ] == " test" );
41
+ }
42
+
43
+ SECTION (" GET request with multiple query parameters" )
44
+ {
45
+ SimpleHttp::HttpUrl &httpUrl = url
46
+ .with_path_segments (SimpleHttp::PathSegments{{SimpleHttp::PathSegment{" get_full" }}})
47
+ .with_query_parameters (SimpleHttp::QueryParameters{{
48
+ {SimpleHttp::QueryParameterKey{" first" }, SimpleHttp::QueryParameterValue{" simple" }},
49
+ {SimpleHttp::QueryParameterKey{" last" }, SimpleHttp::QueryParameterValue{" http" }}
50
+ }});
51
+ auto maybe_response = client.get (httpUrl);
52
+
53
+ REQUIRE (maybe_response);
54
+
55
+ SimpleHttp::HttpResponse response = maybe_response.value ();
56
+ auto keys = nlohmann::json::parse (response.body .value ());
57
+
58
+ CHECK (keys[" first" ] == " simple" );
59
+ CHECK (keys[" last" ] == " http" );
60
+ }
25
61
26
- SECTION (" Post request" )
62
+ SECTION (" POST request" )
27
63
{
28
64
auto maybe_response = client.post (url.with_path_segments (SimpleHttp::PathSegments{{SimpleHttp::PathSegment{" post" }}}),
29
65
SimpleHttp::HttpRequestBody{R"( {"name":"test"})" },
@@ -37,7 +73,7 @@ TEST_CASE("Integration Tests")
37
73
CHECK (keys[" hello" ] == " test" );
38
74
}
39
75
40
- SECTION (" Put request" )
76
+ SECTION (" PUT request" )
41
77
{
42
78
auto maybe_response = client.put (url.with_path_segments (SimpleHttp::PathSegments{{SimpleHttp::PathSegment{" put" }}}),
43
79
SimpleHttp::HttpRequestBody{R"( {"update":"test"})" },
@@ -51,23 +87,23 @@ TEST_CASE("Integration Tests")
51
87
CHECK (keys[" update" ] == " test" );
52
88
}
53
89
54
- SECTION (" Delete request" )
90
+ SECTION (" DELETE request" )
55
91
{
56
92
auto maybe_response = client.del (url.with_path_segments (SimpleHttp::PathSegments{{SimpleHttp::PathSegment{" delete" }}}));
57
93
58
94
REQUIRE (maybe_response);
59
95
CHECK (maybe_response.value ().status == SimpleHttp::OK);
60
96
}
61
97
62
- SECTION (" Head request" )
98
+ SECTION (" HEAD request" )
63
99
{
64
100
auto maybe_response = client.head (url.with_path_segments (SimpleHttp::PathSegments{{SimpleHttp::PathSegment{" get" }}}));
65
101
66
102
REQUIRE (maybe_response);
67
103
CHECK (maybe_response.value ().status == SimpleHttp::OK);
68
104
}
69
105
70
- SECTION (" Options request" )
106
+ SECTION (" OPTIONS request" )
71
107
{
72
108
auto maybe_response = client.options (url.with_path_segments (SimpleHttp::PathSegments{{SimpleHttp::PathSegment{" get" }}}));
73
109
@@ -78,7 +114,7 @@ TEST_CASE("Integration Tests")
78
114
Catch::UnorderedEquals (std::vector<std::string>{" HEAD" , " OPTIONS" , " GET" }));
79
115
}
80
116
81
- SECTION (" Trace request" )
117
+ SECTION (" TRACE request" )
82
118
{
83
119
auto maybe_response = client.trace (url.with_path_segments (SimpleHttp::PathSegments{{SimpleHttp::PathSegment{" trace" }}}));
84
120
@@ -96,7 +132,7 @@ TEST_CASE("Integration Tests")
96
132
CHECK (error == " Error: Unsupported protocol" );
97
133
}
98
134
99
- SECTION (" Post request that expects a 204 NO_CONTENT response" )
135
+ SECTION (" POST request that expects a 204 NO_CONTENT response" )
100
136
{
101
137
auto maybe_response = client.post (url.with_path_segments (SimpleHttp::PathSegments{{SimpleHttp::PathSegment{" empty_post_response" }}}),
102
138
SimpleHttp::HttpRequestBody{" " },
@@ -111,7 +147,7 @@ TEST_CASE("Integration Tests")
111
147
CHECK (response.body .value ().empty ());
112
148
}
113
149
114
- SECTION (" Get request that expects a 405 METHOD_NOT_ALLOWED response" )
150
+ SECTION (" GET request that expects a 405 METHOD_NOT_ALLOWED response" )
115
151
{
116
152
auto maybe_response = client.get (url.with_path_segments (SimpleHttp::PathSegments{{SimpleHttp::PathSegment{" empty_post_response" }}}),
117
153
SimpleHttp::eq (SimpleHttp::METHOD_NOT_ALLOWED));
0 commit comments