Added tests.
Build and Test Module / build-and-test (push) Successful in 21s Details
Build and Test Module / integration-tests (push) Successful in 23s Details

This commit is contained in:
Andrew Lalis 2025-06-29 11:42:36 -04:00
parent d5a09c0421
commit d1263a5991
5 changed files with 27 additions and 7 deletions

View File

@ -28,5 +28,5 @@ jobs:
compiler: ldc-latest
- name: http1-test
working-directory: integration-tests
working-directory: integration-tests/http1-basic
run: dub run --single http1-test.d

View File

@ -1,5 +1,5 @@
/+ dub.sdl:
dependency "handy-http-transport" path="../"
dependency "handy-http-transport" path="../../"
dependency "requests" version="~>2.1"
+/
@ -24,11 +24,7 @@ int main() {
.build();
configureLoggingProvider(loggingProvider);
HttpTransport transport = new Http1Transport(HttpRequestHandler.of((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!");
}));
HttpTransport transport = new Http1Transport(HttpRequestHandler.of(&handleRequest));
Thread thread = transport.startInNewThread();
scope(exit) {
transport.stop();
@ -38,6 +34,7 @@ int main() {
Thread.sleep(msecs(100)); // Wait for the server to start.
// Send a simple GET request to the server.
info("Sending GET request to http://localhost:8080");
auto content = getContent("http://localhost:8080");
ubyte[] data = content.data;
if (data.length != 13 || (cast(string) data) != "Hello, world!") {
@ -48,3 +45,9 @@ int main() {
info("Test completed successfully.");
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!");
}

View File

@ -0,0 +1,6 @@
module integration_tests.http1_speed_test;
void main() {
}

11
integration-tests/run_all.sh Executable file
View File

@ -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 ..