Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 7263c18

Browse files
author
Jean-Christophe Sirot
committed
Update e2e tests
Signed-off-by: Jean-Christophe Sirot <[email protected]>
1 parent 154c45c commit 7263c18

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

e2e/commands_test.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
4848
dir := fs.NewDir(t, "")
4949
defer dir.Remove()
5050

51+
// Build the App
52+
cmd.Command = dockerCli.Command("app", "build", ".", "--folder", filepath.Join(appPath, "my.dockerapp"), "--tag", "a-simple-tag", "--no-resolve-image")
53+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
54+
55+
// Render the App
5156
envParameters := map[string]string{}
5257
data, err := ioutil.ReadFile(filepath.Join(appPath, "env.yml"))
5358
assert.NilError(t, err)
5459
assert.NilError(t, yaml.Unmarshal(data, &envParameters))
55-
args := dockerCli.Command("app", "render", filepath.Join(appPath, "my.dockerapp"), "--parameters-file", filepath.Join(appPath, "parameters-0.yml"))
60+
args := dockerCli.Command("app", "render", "a-simple-tag", "--parameters-file", filepath.Join(appPath, "parameters-0.yml"))
5661
for k, v := range envParameters {
5762
args = append(args, "--set", fmt.Sprintf("%s=%s", k, v))
5863
}
@@ -70,6 +75,18 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
7075
}
7176
}
7277

78+
func TestRenderAppDirectoryFails(t *testing.T) {
79+
cmd, cleanup := dockerCli.createTestCmd()
80+
defer cleanup()
81+
appPath := filepath.Join("testdata", "envfile", "envfile.dockerapp")
82+
83+
cmd.Command = dockerCli.Command("app", "render", appPath)
84+
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
85+
ExitCode: 1,
86+
Err: fmt.Sprintf("%q looks like a docker App directory and App must be built first before rendering", appPath),
87+
})
88+
}
89+
7390
func TestRenderFormatters(t *testing.T) {
7491
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
7592
cmd := info.configuredCmd

e2e/envfile_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ func TestRenderWithEnvFile(t *testing.T) {
1212
defer cleanup()
1313
appPath := filepath.Join("testdata", "envfile", "envfile.dockerapp")
1414

15-
cmd.Command = dockerCli.Command("app", "render", appPath)
15+
cmd.Command = dockerCli.Command("app", "build", "-f", appPath, "--tag", "a-simple-tag", "--no-resolve-image", ".")
16+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
17+
18+
cmd.Command = dockerCli.Command("app", "render", "a-simple-tag")
1619
icmd.RunCmd(cmd).Assert(t, icmd.Expected{Out: `version: "3.7"
1720
services:
1821
db:

internal/commands/render.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
"os"
8+
"strings"
89

910
"github.com/deislabs/cnab-go/action"
1011
"github.com/docker/app/internal"
@@ -77,6 +78,9 @@ func prepareCustomAction(actionName string, dockerCli command.Cli, appname strin
7778
}
7879
bundle, ref, err := cnab.GetBundle(dockerCli, bundleStore, appname)
7980
if err != nil {
81+
if strings.HasSuffix(appname, ".dockerapp") {
82+
return nil, nil, nil, fmt.Errorf("%q looks like a docker App directory and App must be built first before rendering", appname)
83+
}
8084
return nil, nil, nil, err
8185
}
8286
installation, err := appstore.NewInstallation("custom-action", ref.String())

0 commit comments

Comments
 (0)