mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Succeed cloud workspace deletion if the workspace does not exist
This commit is contained in:
@@ -526,6 +526,10 @@ func (b *Cloud) DeleteWorkspace(name string, force bool) error {
|
||||
}
|
||||
|
||||
workspace, err := b.client.Workspaces.Read(context.Background(), b.organization, name)
|
||||
if err == tfe.ErrResourceNotFound {
|
||||
return nil // If the workspace does not exist, succeed
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to retrieve workspace %s: %v", name, err)
|
||||
}
|
||||
|
||||
@@ -1211,10 +1211,7 @@ func TestClodBackend_DeleteWorkspace_DoesNotExist(t *testing.T) {
|
||||
defer bCleanup()
|
||||
|
||||
err := b.DeleteWorkspace("non-existent-workspace", false)
|
||||
if err == nil {
|
||||
t.Fatalf("expected deleting a workspace which does not exist to fail")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "failed to retrieve workspace non-existent-workspace") {
|
||||
t.Fatalf("expected deletion to fail with cannot find workspace error, but got %s", err.Error())
|
||||
if err != nil {
|
||||
t.Fatalf("expected deleting a workspace which does not exist to succeed")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user