Skip to content

Commit

Permalink
Adds name and host name to RunWithOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilde authored and arekkas committed Nov 30, 2017
1 parent 0c237ab commit b7100a8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
8 changes: 1 addition & 7 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dockertest.go
Expand Up @@ -119,6 +119,8 @@ func shouldPreferTls(endpoint string) bool {

// RunOptions is used to pass in optional parameters when running a container.
type RunOptions struct {
Hostname string
Name string
Repository string
Tag string
Env []string
Expand Down Expand Up @@ -178,7 +180,9 @@ func (d *Pool) RunWithOptions(opts *RunOptions) (*Resource, error) {
}

c, err := d.Client.CreateContainer(dc.CreateContainerOptions{
Name: opts.Name,
Config: &dc.Config{
Hostname: opts.Hostname,
Image: fmt.Sprintf("%s:%s", repository, tag),
Env: env,
Entrypoint: ep,
Expand Down
13 changes: 13 additions & 0 deletions dockertest_test.go
Expand Up @@ -72,3 +72,16 @@ func TestMongo(t *testing.T) {
require.Nil(t, err)
require.Nil(t, pool.Purge(resource))
}

func TestContainerWithName(t *testing.T) {
resource, err := pool.RunWithOptions(
&RunOptions{
Name: "db",
Repository: "postgres",
Tag: "9.5",
})
require.Nil(t, err)
assert.Equal(t,"/db", resource.Container.Name)

require.Nil(t, pool.Purge(resource))
}

0 comments on commit b7100a8

Please sign in to comment.