Skip to content

Commit

Permalink
[merge] pull request #1139
Browse files Browse the repository at this point in the history
  • Loading branch information
ddollar committed Aug 25, 2016
2 parents b448b59 + 27e098e commit 2903327
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion manifest/process.go
Expand Up @@ -90,7 +90,7 @@ func NewProcess(app string, s Service, m Manifest) Process {
args = append(args, s.Tag(app))

if s.Command.String != "" {
args = append(args, s.Command.String)
args = append(args, "sh", "-c", s.Command.String)
} else if len(s.Command.Array) > 0 {
args = append(args, s.Command.Array...)
}
Expand Down
40 changes: 39 additions & 1 deletion manifest/process_test.go
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestNewProcess(t *testing.T) {
func TestProcessNew(t *testing.T) {
s := manifest.Service{
Name: "foo",
Volumes: []string{
Expand Down Expand Up @@ -44,3 +44,41 @@ func TestNewProcess(t *testing.T) {
assert.Equal(t, p.Name, "api-foo")
assert.Equal(t, p.Args, expectedArgs)
}

func TestProcessCommandString(t *testing.T) {
s := manifest.Service{
Name: "foo",
Command: manifest.Command{String: "ls -la"},
}

m := manifest.Manifest{
Services: map[string]manifest.Service{
"foo": s,
},
}

p := manifest.NewProcess("api", s, m)

if assert.NotNil(t, p) {
assert.Equal(t, []string{"-i", "--rm", "--name", "api-foo", "api/foo", "sh", "-c", "ls -la"}, p.Args)
}
}

func TestProcessStringArray(t *testing.T) {
s := manifest.Service{
Name: "foo",
Command: manifest.Command{Array: []string{"ls", "-la"}},
}

m := manifest.Manifest{
Services: map[string]manifest.Service{
"foo": s,
},
}

p := manifest.NewProcess("api", s, m)

if assert.NotNil(t, p) {
assert.Equal(t, []string{"-i", "--rm", "--name", "api-foo", "api/foo", "ls", "-la"}, p.Args)
}
}

0 comments on commit 2903327

Please sign in to comment.