mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
cli: remove state on terminate (#2359)
This commit is contained in:
parent
4680882708
commit
36467bf084
@ -88,6 +88,10 @@ func terminate(cmd *cobra.Command, terminator cloudTerminator, fileHandler file.
|
||||
removeErr = errors.Join(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", pf.PrefixPrintablePath(constants.ClusterIDsFilename)))
|
||||
}
|
||||
|
||||
if err := fileHandler.Remove(constants.StateFilename); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||
removeErr = errors.Join(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", pf.PrefixPrintablePath(constants.StateFilename)))
|
||||
}
|
||||
|
||||
return removeErr
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@ func TestTerminate(t *testing.T) {
|
||||
fileHandler := file.NewHandler(fs)
|
||||
require.NoError(fileHandler.Write(constants.AdminConfFilename, []byte{1, 2}, file.OptNone))
|
||||
require.NoError(fileHandler.WriteJSON(constants.ClusterIDsFilename, idFile, file.OptNone))
|
||||
require.NoError(fileHandler.Write(constants.StateFilename, []byte{3, 4}, file.OptNone))
|
||||
return fs
|
||||
}
|
||||
someErr := errors.New("failed")
|
||||
@ -160,6 +161,8 @@ func TestTerminate(t *testing.T) {
|
||||
assert.Error(err)
|
||||
_, err = fileHandler.Stat(constants.ClusterIDsFilename)
|
||||
assert.Error(err)
|
||||
_, err = fileHandler.Stat(constants.StateFilename)
|
||||
assert.Error(err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user