forked from getporter/porter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade should not be allowed if installation is not installed (getpo…
…rter#3213) fix: Upgrade should not be allowed if installation is not installed Signed-off-by: Kim Christensen <kimworking@gmail.com> Signed-off-by: John Cudd <jmcudd@gmail.com>
- Loading branch information
1 parent
84ca7ee
commit be10921
Showing
5 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/integration/testdata/bundles/bundle-with-failing-install/helpers.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
install() { | ||
echo Hello World | ||
exit 1 | ||
} | ||
|
||
upgrade() { | ||
echo World 2.0 | ||
} | ||
|
||
uninstall() { | ||
echo Goodbye World | ||
} | ||
|
||
# Call the requested function and pass the arguments as-is | ||
"$@" |
29 changes: 29 additions & 0 deletions
29
tests/integration/testdata/bundles/bundle-with-failing-install/porter.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
schemaVersion: 1.0.1 | ||
name: porter-failing-install | ||
version: 0.1.0 | ||
description: "A bundle that always fails installation" | ||
registry: "localhost:5000" | ||
|
||
mixins: | ||
- exec | ||
|
||
install: | ||
- exec: | ||
description: "Install Hello World" | ||
command: ./helpers.sh | ||
arguments: | ||
- install | ||
|
||
upgrade: | ||
- exec: | ||
description: "Upgrade Hello World" | ||
command: ./helpers.sh | ||
arguments: | ||
- upgrade | ||
|
||
uninstall: | ||
- exec: | ||
description: "Uninstall Hello World" | ||
command: ./helpers.sh | ||
arguments: | ||
- uninstall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//go:build integration | ||
|
||
package integration | ||
|
||
import ( | ||
"testing" | ||
|
||
"get.porter.sh/porter/pkg/porter" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestUpgrade_failedInstallation(t *testing.T) { | ||
p := porter.NewTestPorter(t) | ||
defer p.Close() | ||
ctx := p.SetupIntegrationTest() | ||
|
||
p.AddTestBundleDir("testdata/bundles/bundle-with-failing-install", false) | ||
|
||
installOpts := porter.NewInstallOptions() | ||
err := installOpts.Validate(ctx, []string{}, p.Porter) | ||
require.NoError(t, err) | ||
|
||
err = p.InstallBundle(ctx, installOpts) | ||
require.Error(t, err, "Installation should fail") | ||
|
||
upgradeOpts := porter.NewUpgradeOptions() | ||
err = upgradeOpts.Validate(ctx, []string{}, p.Porter) | ||
require.NoError(t, err) | ||
|
||
err = p.UpgradeBundle(ctx, upgradeOpts) | ||
require.Error(t, err, "Upgrade should fail, because the installation failed") | ||
} |