microcks / microcks-testcontainers-go

Go lib for Testcontainers that enables embedding Microcks into your unit tests with lightweight, throwaway instance thanks to containers.
https://microcks.io
Apache License 2.0
6 stars 4 forks source link

Allow specification of artifacts to load on MicrocksContainer creation #11

Closed lbroudoux closed 8 months ago

lbroudoux commented 8 months ago

Reason/Context

As of today, loading artifacts into the Microcks container should be done after the container is started-up using 2 methods:

However, this way of doing things doesn't really fit with existing modules' logic - all of them have WithSomething() fluent API style methods that allow config definition at creation. Moreover, our approach can sometimes be harder to achieve cause it means you have to retrieve the container once initialized (depending on the test framework, this can be tricky) to import artifacts.

Description

Ideally, we'd like to be able to have something like:

microcksContainer, err := microcks.RunContainer(ctx, 
   testcontainers.WithImage("quay.io/microcks/microcks-uber:nightly"),
   testcontainers.WithPrimaryArtifact("testdata/apipastries-openapi.yaml"))

Implementation ideas

See if implementation ideas from https://github.com/microcks/microcks-testcontainers-java/issues/26 can be reused/adapted here to Go

JulienBreux commented 8 months ago

Note: I replace Primary by Main to push strong consistency 😉

lbroudoux commented 8 months ago

Now solved with #14. Thanks to @JulienBreux!