Golang Test Container
This image permits to run all the tests of your project, automatically including modules under pkg and internal directories.
Supported tags are defined in the versions.txt.
If you want a new tag, you can make a Merge request and update this file.
You can use it easily in a docker-compose.yml:
version: "3"
services:
test:
image: henri9813/golang-test:1
working_dir: $PWD
volumes:
- $PWD:$PWDHere is the tests result:
$ docker-compose up test
Starting golang-test_test_1 ... done
Attaching to golang-test_test_1
test_1 | ? project [no test files]
test_1 | ok project/pkg/substration 0.001s coverage: 33.3% of statements in project/pkg/substration, project
golang-test_test_1 exited with code 0
Execute a script before run the tests ( usefull for preseeding a databse for example )
Set to true if you are running a package without go.mod.
this permit to avoid this error:
cannot find package "." in:
/my_package
Permit to define a list of packages separated by spaces to exclude from the test.
Example:
export EXCLUDED_PACKAGES="pkg/addition internal/excludedpackage1"
Permit to add a COVERAGE_FILES_NAME_PREFIX before the cover.out and cover.html.
Example:
export COVERAGE_FILES_NAME_PREFIX=project1_
...
$ ls
...
project1_cover.html
project1_cover.out
Allows you to pass additional arguments to the go test command.
Example:
export GO_TEST_ARGS='-gcflags="all=-N -l" -count=1'