Added tests.
This commit is contained in:
parent
d5a09c0421
commit
d1263a5991
|
@ -28,5 +28,5 @@ jobs:
|
||||||
compiler: ldc-latest
|
compiler: ldc-latest
|
||||||
|
|
||||||
- name: http1-test
|
- name: http1-test
|
||||||
working-directory: integration-tests
|
working-directory: integration-tests/http1-basic
|
||||||
run: dub run --single http1-test.d
|
run: dub run --single http1-test.d
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/+ dub.sdl:
|
/+ dub.sdl:
|
||||||
dependency "handy-http-transport" path="../"
|
dependency "handy-http-transport" path="../../"
|
||||||
dependency "requests" version="~>2.1"
|
dependency "requests" version="~>2.1"
|
||||||
+/
|
+/
|
||||||
|
|
||||||
|
@ -24,11 +24,7 @@ int main() {
|
||||||
.build();
|
.build();
|
||||||
configureLoggingProvider(loggingProvider);
|
configureLoggingProvider(loggingProvider);
|
||||||
|
|
||||||
HttpTransport transport = new Http1Transport(HttpRequestHandler.of((ref ServerHttpRequest request, ref ServerHttpResponse response) {
|
HttpTransport transport = new Http1Transport(HttpRequestHandler.of(&handleRequest));
|
||||||
response.headers.add("Content-Type", "text/plain");
|
|
||||||
response.headers.add("Content-Length", "13");
|
|
||||||
response.outputStream.writeToStream(cast(ubyte[]) "Hello, world!");
|
|
||||||
}));
|
|
||||||
Thread thread = transport.startInNewThread();
|
Thread thread = transport.startInNewThread();
|
||||||
scope(exit) {
|
scope(exit) {
|
||||||
transport.stop();
|
transport.stop();
|
||||||
|
@ -38,6 +34,7 @@ int main() {
|
||||||
Thread.sleep(msecs(100)); // Wait for the server to start.
|
Thread.sleep(msecs(100)); // Wait for the server to start.
|
||||||
|
|
||||||
// Send a simple GET request to the server.
|
// Send a simple GET request to the server.
|
||||||
|
info("Sending GET request to http://localhost:8080");
|
||||||
auto content = getContent("http://localhost:8080");
|
auto content = getContent("http://localhost:8080");
|
||||||
ubyte[] data = content.data;
|
ubyte[] data = content.data;
|
||||||
if (data.length != 13 || (cast(string) data) != "Hello, world!") {
|
if (data.length != 13 || (cast(string) data) != "Hello, world!") {
|
||||||
|
@ -48,3 +45,9 @@ int main() {
|
||||||
info("Test completed successfully.");
|
info("Test completed successfully.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleRequest(ref ServerHttpRequest request, ref ServerHttpResponse response) {
|
||||||
|
response.headers.add("Content-Type", "text/plain");
|
||||||
|
response.headers.add("Content-Length", "13");
|
||||||
|
response.outputStream.writeToStream(cast(ubyte[]) "Hello, world!");
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
module integration_tests.http1_speed_test;
|
||||||
|
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This script runs all integration tests.
|
||||||
|
|
||||||
|
set -e -o pipefail
|
||||||
|
|
||||||
|
cd http1-basic
|
||||||
|
dub build --single http1-test.d
|
||||||
|
./http1-test
|
||||||
|
|
||||||
|
cd ..
|
Loading…
Reference in New Issue