|
|
@ -17,6 +17,8 @@ limitations under the License.
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/pkg/chart"
|
|
|
|
"helm.sh/helm/v3/pkg/chart"
|
|
|
@ -121,3 +123,44 @@ func TestRollbackFileCompletion(t *testing.T) {
|
|
|
|
checkFileCompletion(t, "rollback myrelease", false)
|
|
|
|
checkFileCompletion(t, "rollback myrelease", false)
|
|
|
|
checkFileCompletion(t, "rollback myrelease 1", false)
|
|
|
|
checkFileCompletion(t, "rollback myrelease 1", false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestRollbackWithLabels(t *testing.T) {
|
|
|
|
|
|
|
|
labels1 := map[string]string{"operation": "install", "firstLabel": "firstValue"}
|
|
|
|
|
|
|
|
labels2 := map[string]string{"operation": "upgrade", "secondLabel": "secondValue"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
releaseName := "funny-bunny-labels"
|
|
|
|
|
|
|
|
rels := []*release.Release{
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Name: releaseName,
|
|
|
|
|
|
|
|
Info: &release.Info{Status: release.StatusSuperseded},
|
|
|
|
|
|
|
|
Chart: &chart.Chart{},
|
|
|
|
|
|
|
|
Version: 1,
|
|
|
|
|
|
|
|
Labels: labels1,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Name: releaseName,
|
|
|
|
|
|
|
|
Info: &release.Info{Status: release.StatusDeployed},
|
|
|
|
|
|
|
|
Chart: &chart.Chart{},
|
|
|
|
|
|
|
|
Version: 2,
|
|
|
|
|
|
|
|
Labels: labels2,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
storage := storageFixture()
|
|
|
|
|
|
|
|
for _, rel := range rels {
|
|
|
|
|
|
|
|
if err := storage.Create(rel); err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_, _, err := executeActionCommandC(storage, fmt.Sprintf("rollback %s 1", releaseName))
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Errorf("unexpected error, got '%v'", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
updatedRel, err := storage.Get(releaseName, 3)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Errorf("unexpected error, got '%v'", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(updatedRel.Labels, labels1) {
|
|
|
|
|
|
|
|
t.Errorf("Expected {%v}, got {%v}", labels1, updatedRel.Labels)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|