@ -169,7 +169,7 @@ func TestRollbackWithReleaseVersion(t *testing.T) {
// check that v2 is now in a SUPERSEDED state
oldRel , err := rs . env . Releases . Get ( rel . Name , 2 )
if err != nil {
t . Fatalf ( "Failed to retrieve v 1 : %s", err )
t . Fatalf ( "Failed to retrieve v 2 : %s", err )
}
if oldRel . Info . Status . Code != release . Status_SUPERSEDED {
t . Errorf ( "Expected v2 to be in a SUPERSEDED state, got %q" , oldRel . Info . Status . Code )
@ -184,6 +184,72 @@ func TestRollbackWithReleaseVersion(t *testing.T) {
}
}
func TestRollbackDeleted ( t * testing . T ) {
c := helm . NewContext ( )
rs := rsFixture ( )
rs . Log = t . Logf
rs . env . Releases . Log = t . Logf
rel2 := releaseStub ( )
rel2 . Name = "other"
rs . env . Releases . Create ( rel2 )
rel := releaseStub ( )
rs . env . Releases . Create ( rel )
v2 := upgradeReleaseVersion ( rel )
rs . env . Releases . Update ( rel )
rs . env . Releases . Create ( v2 )
v3 := upgradeReleaseVersion ( v2 )
// retain the original release as DEPLOYED while the update should fail
v2 . Info . Status . Code = release . Status_DEPLOYED
v3 . Info . Status . Code = release . Status_FAILED
rs . env . Releases . Update ( v2 )
rs . env . Releases . Create ( v3 )
req1 := & services . UninstallReleaseRequest {
Name : rel . Name ,
DisableHooks : true ,
}
_ , err := rs . UninstallRelease ( c , req1 )
if err != nil {
t . Fatalf ( "Failed uninstall: %s" , err )
}
oldRel , err := rs . env . Releases . Get ( rel . Name , 3 )
if err != nil {
t . Fatalf ( "Failed to retrieve v3: %s" , err )
}
if oldRel . Info . Status . Code != release . Status_DELETED {
t . Errorf ( "Expected v3 to be in a DELETED state, got %q" , oldRel . Info . Status . Code )
}
req2 := & services . RollbackReleaseRequest {
Name : rel . Name ,
DisableHooks : true ,
Version : 2 ,
}
_ , err = rs . RollbackRelease ( c , req2 )
if err != nil {
t . Fatalf ( "Failed rollback: %s" , err )
}
// check that v3 is now in a SUPERSEDED state
oldRel , err = rs . env . Releases . Get ( rel . Name , 3 )
if err != nil {
t . Fatalf ( "Failed to retrieve v3: %s" , err )
}
if oldRel . Info . Status . Code != release . Status_SUPERSEDED {
t . Errorf ( "Expected v3 to be in a SUPERSEDED state, got %q" , oldRel . Info . Status . Code )
}
// make sure we didn't update some other deployments.
otherRel , err := rs . env . Releases . Get ( rel2 . Name , 1 )
if err != nil {
t . Fatalf ( "Failed to retrieve other v1: %s" , err )
}
if otherRel . Info . Status . Code != release . Status_DEPLOYED {
t . Errorf ( "Expected other deployed release to stay untouched, got %q" , otherRel . Info . Status . Code )
}
}
func TestRollbackReleaseNoHooks ( t * testing . T ) {
c := helm . NewContext ( )
rs := rsFixture ( )