testcontainers / testcontainers-c Goto Github PK
View Code? Open in Web Editor NEWTestcontainers for C and, soon, C++, built on the top of Testcontainers for Go. Includes a WireMock module for test/demo purposes
License: MIT License
Testcontainers for C and, soon, C++, built on the top of Testcontainers for Go. Includes a WireMock module for test/demo purposes
License: MIT License
Since I am working on WireMock, I want to have it as a first PoC module for the implementation. The module would provide additional APIs for management, etc
When using CGO, structures like this one are generated:
/* Return type for RunContainer */
struct RunContainer_return {
GoInt r0; /* id */
char* r1; /* errstr */
};
extern struct RunContainer_return RunContainer(GoInt requestID);
/* Return type for GetURI */
struct GetURI_return {
GoString r0; /* uri */
GoInterface r1; /* e */
};
Maybe CGO could be tweaked or configured to inject proper field names to improve DevX
This is how we want to see the code once everything is done, maybe:
#include <stdio.h>
#include <string.h>
#include "testcontainers-c.h"
#include "testcontainers-c-wiremock.h"
#define DEFAULT_IMAGE "wiremock/wiremock:3.1.0-1"
int main() {
printf("Using WireMock with the Testcontainers C binding:\n");
printf("Creating new container: %s\n", DEFAULT_IMAGE);
int requestId = NewContainerRequest(DEFAULT_IMAGE);
WithExposedTcpPort(requestId, 8080);
WithWaitForHttp(requestId, 8080, "/__admin/mappings");
WithFile(requestId, "test_data/hello.json", "/home/wiremock/mappings/hello.json");
struct TestContainer container = RunContainer(requestId);
if (container.Id == -1) {
printf("Failed to run the container: %s\n", container.errorMsg);
return -1;
}
printf("Sending HTTP request to the container\n");
struct HttpGetResponse response = SendHttpGet(container.Id, 8080, "/hello");
if (response.code == -1) {
printf("Failed to send HTTP request: %s\n", response.errorMsg);
return -1;
}
if (response.code != 200) {
printf("Request failed: HTTP-%d\n%s\n", response.code, response.errorMsg);
return -1;
}
printf("Server Response: HTTP-%d\n%s\n\n", response.code, response.msg);
return 0;
}
Currently a lot of GString / GInt are used. It would be nice to switch to basic types so that API is easier to use. Golang code is highly customized anyway
It would be great to have a CppUnit Demo showcasing integration of the library, with automatic teardown of the container
We use Testcontainers Go under the hood. It would be nice to extend the wrapper API
Each is likely a separate pull request or EPIC on its own
It would be nice to publish the Testcontainers packages to vcpkg
It would be nice to initialize the documentation structure, published to GitHub Pages
The current C API is quite complicated for consumption. It would be great to have a C++ binding with
It is not there yet :(
Once we generate testcontainers-c.h
, we can use Doxygen to build code documentation in the documentation pipeline. It is unlikely to be trivial, because not all data is propagated to header files. Waybe CGO could be tweaked to inject more information
Currently we have a CTest test suite inside the code, and it is a good start for tests. At the same time, it would be nice to have another example that uses the code as an external package in the examples
It would be nice to publish the Testcontainers packages to Conan
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.