GithubHelp home page GithubHelp logo

testcontainers / testcontainers-c Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 1.0 254 KB

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

Go 49.08% C 28.45% CMake 22.47%
c cpp testcontainers wiremock hacktoberfest testcontainers-custom-container

testcontainers-c's Issues

Inject informative field names into C Structures

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

Wishlist

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;
}

Switch API to use native C types

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

Add CppUnit demo

It would be great to have a CppUnit Demo showcasing integration of the library, with automatic teardown of the container

vcpkg packaging

It would be nice to publish the Testcontainers packages to vcpkg

  • Add package and build definitions
  • Register the package on vcpkg
  • Add publishing to GitHub Actions

References

Initial Documentation structure

It would be nice to initialize the documentation structure, published to GitHub Pages

  • Overview
  • Quickstart
  • Feature docs
  • Placeholder for Doxygen-generated code docs

Add C++ binding library

The current C API is quite complicated for consumption. It would be great to have a C++ binding with

  • Namespace
  • Proper Structures
  • TBD: Classes

Add standalone CUnit Example

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

Conan packaging

It would be nice to publish the Testcontainers packages to Conan

  • Add package and build definitions
  • Register the package on vcpkg
  • Add publishing to GitHub Actions

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.