Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prints generated Dockerfile lines nicely #178

Merged
merged 2 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/porter/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func (p *Porter) buildDockerFile() ([]string, error) {
lines = append(lines, p.buildPorterSection()...)
lines = append(lines, p.buildCMDSection())

fmt.Fprintln(p.Out, lines)
for _, line := range lines {
fmt.Fprintln(p.Out, line)
}

return lines, nil
}
Expand Down
28 changes: 28 additions & 0 deletions pkg/porter/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,34 @@ func TestPorter_buildDockerfile(t *testing.T) {
assert.Equal(t, wantlines, gotlines)
}

func TestPorter_buildDockerfile_output(t *testing.T) {
p := NewTestPorter(t)
p.TestConfig.SetupPorterHome()
configTpl, err := p.TestConfig.GetPorterConfigTemplate()
require.Nil(t, err)
p.TestConfig.TestContext.AddTestFileContents(configTpl, config.Name)

err = p.LoadManifest()
require.NoError(t, err)

// ignore mixins in the unit tests
p.Manifest.Mixins = []string{}

_, err = p.buildDockerFile()
require.NoError(t, err)

wantlines := `
Generating Dockerfile =======>
FROM quay.io/deis/lightweight-docker-go:v0.2.0
FROM debian:stretch
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY cnab/ /cnab/
COPY porter.yaml /cnab/app/porter.yaml
CMD ["/cnab/app/run"]
`
assert.Equal(t, wantlines, p.TestConfig.TestContext.GetOutput())
}

func TestPorter_generateDockerfile(t *testing.T) {
p := NewTestPorter(t)
p.TestConfig.SetupPorterHome()
Expand Down