Fix broken rename behavior in tfe_client_mock.go

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.
pull/29826/head
Nick Fagerlund 5 years ago committed by Chris Arcand
parent 50997d9a32
commit fabd8eb0b6

@ -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

Loading…
Cancel
Save