From fabd8eb0b63b1489e24c7be95636611e29fb8696 Mon Sep 17 00:00:00 2001 From: Nick Fagerlund Date: Tue, 26 Oct 2021 17:02:28 -0700 Subject: [PATCH] Fix broken rename behavior in tfe_client_mock.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The delete + assign at the end of `Update` and `UpdateByID` are meant to handle renaming a workspace — (remove old name), (insert new name). However, `UpdateByID` was doing (remove new name), (insert new name) and leaving the old name in place. This commit changes it to match `Update` by grabbing the original name off the workspace object _before_ potentially renaming it. --- internal/cloud/tfe_client_mock.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/cloud/tfe_client_mock.go b/internal/cloud/tfe_client_mock.go index 8ba6883c3..ecc3b9add 100644 --- a/internal/cloud/tfe_client_mock.go +++ b/internal/cloud/tfe_client_mock.go @@ -1255,12 +1255,13 @@ func (m *MockWorkspaces) UpdateByID(ctx context.Context, workspaceID string, opt return nil, tfe.ErrResourceNotFound } + originalName := w.Name err := updateMockWorkspaceAttributes(w, options) if err != nil { return nil, err } - delete(m.workspaceNames, w.Name) + delete(m.workspaceNames, originalName) m.workspaceNames[w.Name] = w return w, nil