Skip to content

Commit

Permalink
Merge pull request #16 from pvormste/prerelease-fix
Browse files Browse the repository at this point in the history
Prerelease fix
  • Loading branch information
pvormste authored Mar 12, 2019
2 parents 2aa1b9c + 9007ca6 commit 08e9ba6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dockertestwrapper [![Build Status](https://travis-ci.org/pvormste/dockertestwrapper.svg?branch=master)](https://travis-ci.org/pvormste/dockertestwrapper)

As the name suggests dockertestwrapper is a wrapper for orys awesome [dockertest library](https://github.com/ory/dockertest).
As the name suggests dockertestwrapper is a wrapper for [orys awesome dockertest library](https://github.com/ory/dockertest).
It provides an easy to use api to be used in your integration tests.

## Usage
Expand All @@ -11,8 +11,9 @@ The postgres helper function can be used to start a postgres container with defa

Although it should be possible to start any postgres version with the `InitPostgresContainer` function, following
images are covered by tests in this repository:
- postgres:11
- postgres:10
- postgres:11-alpine
- postgres:10-alpine
- postgres:9.6-alpine

#### Connection details

Expand Down
6 changes: 0 additions & 6 deletions pkg/dockertestwrapper/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import (
// PostgresImageName is the image name of the postgres docker image
const PostgresImageName string = "postgres"

// Possible postgres image versions
const (
PostgresImageVersion10 string = "10"
PostgresImageVersion11 string = "11"
)

// Default postgres connection details
const (
DefaultPostgresPort string = "5432/tcp"
Expand Down
33 changes: 17 additions & 16 deletions pkg/dockertestwrapper/postgres_integr_test.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
package dockertestwrapper

import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestInitPostgresContainer(t *testing.T) {
t.Run("should start and purge a postgres 11 container successfully", func(t *testing.T) {
wrapper, err := InitPostgresContainer(PostgresImageVersion11)
assert.NoError(t, err)
require.NotNil(t, wrapper)

err = wrapper.PurgeContainer()
assert.NoError(t, err)
})
var postgresImageTags = map[string]string{
"11": "11-alpine",
"10": "10-alpine",
"9.6": "9.6-alpine",
}

t.Run("should start and purge a postgres 10 container successfully", func(t *testing.T) {
wrapper, err := InitPostgresContainer(PostgresImageVersion10)
assert.NoError(t, err)
require.NotNil(t, wrapper)
func TestInitPostgresContainer(t *testing.T) {
for postgresVersion, postgresTag := range postgresImageTags {
it := fmt.Sprintf("should start and purge a postgres %s container successfully", postgresVersion)
t.Run(it, func(t *testing.T) {
wrapper, err := InitPostgresContainer(postgresTag)
assert.NoError(t, err)
require.NotNil(t, wrapper)

err = wrapper.PurgeContainer()
assert.NoError(t, err)
})
err = wrapper.PurgeContainer()
assert.NoError(t, err)
})
}
}

0 comments on commit 08e9ba6

Please sign in to comment.