Skip to content

Commit a3ebaf6

Browse files
author
nikimanoledaki
committed
Update acceptance tests for updating profile
1 parent b20b80f commit a3ebaf6

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

cmd/gitops/update/cmd.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ func UpdateCommand(endpoint *string, client *resty.Client) *cobra.Command {
1212
Use: "update",
1313
Short: "Update a Weave GitOps resource",
1414
Example: `
15-
# Update an installed profile to a certain version
16-
gitops update profile --name <profile-name> --version <version> --config-repo <config-repo-url> --cluster <cluster-name> --namespace <ns-name>
17-
`,
15+
# Update a profile that is installed on a cluster
16+
gitops update profile --name=podinfo --cluster=prod --config-repo=ssh://[email protected]/owner/config-repo.git --version=1.0.0
17+
`,
1818
}
1919

2020
cmd.AddCommand(profiles.UpdateCommand())

cmd/gitops/update/profiles/profiles.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ import (
2424

2525
var opts profiles.UpdateOptions
2626

27-
// UpdateCommand provides support for updating an installed profile's version.
27+
// UpdateCommand provides support for updating a profile that is installed on a cluster.
2828
func UpdateCommand() *cobra.Command {
2929
cmd := &cobra.Command{
3030
Use: "profile",
31-
Short: "Update a profile to a different version",
31+
Short: "Update a profile installation",
3232
SilenceUsage: true,
3333
SilenceErrors: true,
3434
Example: `
35-
# Update an installed profile to a different version
36-
gitops update profile --name=podinfo --cluster=prod --version=1.0.0 --config-repo=ssh://[email protected]/owner/config-repo.git --namespace=test-namespace
35+
# Update a profile that is installed on a cluster
36+
gitops update profile --name=podinfo --cluster=prod --config-repo=ssh://[email protected]/owner/config-repo.git --version=1.0.0
3737
`,
3838
RunE: updateProfileCmdRunE(),
3939
}

pkg/helm/releases_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ var _ = Describe("AppendHelmReleaseToString", func() {
7575
)
7676
})
7777

78-
When("the file does not exist", func() {
79-
It("creates one with the new helm release", func() {
78+
When("the given string is empty", func() {
79+
It("appends a helm release to it", func() {
8080
s, err := helm.AppendHelmReleaseToString("", newRelease)
8181
Expect(err).NotTo(HaveOccurred())
8282
r, err := yaml.Marshal(newRelease)

test/acceptance/test/profiles_test.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,21 @@ Namespace: %s`, clusterName, namespace)))
131131
}, "120s", "1s").Should(Equal(http.StatusOK))
132132

133133
By("Updating the version of the installed profile")
134-
stdOut, stdErr = runCommandAndReturnStringOutput(fmt.Sprintf("%s update profile --name %s --version 6.0.0 --namespace %s --cluster %s --config-repo %s --auto-merge", gitopsBinaryPath, profileName, namespace, clusterName, appRepoRemoteURL))
135-
Expect(stdErr).To(BeEmpty())
134+
time.Sleep(4 * time.Minute)
135+
Eventually(func() string {
136+
stdOut, stdErr = runCommandAndReturnStringOutput(fmt.Sprintf("%s update profile --name %s --version 6.0.0 --namespace %s --cluster %s --config-repo %s --auto-merge", gitopsBinaryPath, profileName, namespace, clusterName, appRepoRemoteURL))
137+
Expect(stdErr).To(BeEmpty())
138+
return stdErr
139+
}, "120s", "5s").Should(BeEmpty())
140+
136141
Expect(stdOut).To(ContainSubstring(
137-
fmt.Sprintf(`Updating 1 profile:
138-
139-
Name: podinfo
140-
Version: 6.0.0
141-
Cluster: %s
142-
Namespace: %s`, clusterName, namespace)))
142+
fmt.Sprintf(
143+
`Updating profile:
144+
145+
Name: podinfo
146+
Version: 6.0.0
147+
Cluster: %s
148+
Namespace: %s`, clusterName, namespace)))
143149

144150
By("Verifying that the profile installed in the cluster's namespace was updated to the correct version")
145151
Eventually(func() int {

0 commit comments

Comments
 (0)