A testing library (for golang projects) to assist in writing integration tests with docker!.
You specify the docker container you want running for your integration tests.
The library will spin it up for your tests to use and tear it down at the end.
Inside your test file:
import "github.com/DennisDenuto/golang-docker-testsuite"
import . "gopkg.in/check.v1"
func Test(t *testing.T) { TestingT(t) }
type LocalDockerSuite struct {
gotestwithdocker.DockerSuite
}
var _ = Suite(&LocalDockerSuite{gotestwithdocker.DockerSuite{ConfigYaml: "./docker-config.yaml"}})
func (s *LocalDockerSuite) TestHappyCase(c *C) {
// your test code here:
// host ip of your test container: os.Getenv("DOCKER_HOST_IP")
// host port of exposed container port: os.Getenv("DOCKER_PORTS_8080/tcp")
}
minimalistic docker-config.yaml
container_name: some-name
image: a-docker-image
docker-config.yaml with exposed ports:
ports:
- 8080:8080
docker-config.yaml wait for container to start up from grepping log message
wait:
log: Some msg from StdOut you should wait for before running tests
docker-config.yaml build a docker image from a DockerFile
container_name: test-container-name
image: image-name-to-use-for-built-docker-image
build:
dockerfile_dir: ./directory-containing-dockerfile
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D