diff --git a/mocks/registry_no_code_module_mocks.go b/mocks/registry_no_code_module_mocks.go index b63b3bf4e..f1e090f26 100644 --- a/mocks/registry_no_code_module_mocks.go +++ b/mocks/registry_no_code_module_mocks.go @@ -56,10 +56,10 @@ func (mr *MockRegistryNoCodeModulesMockRecorder) Create(ctx, organization, optio } // CreateWorkspace mocks base method. -func (m *MockRegistryNoCodeModules) CreateWorkspace(ctx context.Context, noCodeModuleID string, options *tfe.RegistryNoCodeModuleCreateWorkspaceOptions) (*tfe.RegistryNoCodeModuleWorkspace, error) { +func (m *MockRegistryNoCodeModules) CreateWorkspace(ctx context.Context, noCodeModuleID string, options *tfe.RegistryNoCodeModuleCreateWorkspaceOptions) (*tfe.Workspace, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateWorkspace", ctx, noCodeModuleID, options) - ret0, _ := ret[0].(*tfe.RegistryNoCodeModuleWorkspace) + ret0, _ := ret[0].(*tfe.Workspace) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -115,10 +115,10 @@ func (mr *MockRegistryNoCodeModulesMockRecorder) Update(ctx, noCodeModuleID, opt } // UpgradeWorkspace mocks base method. -func (m *MockRegistryNoCodeModules) UpgradeWorkspace(ctx context.Context, noCodeModuleID, workspaceID string, options *tfe.RegistryNoCodeModuleUpgradeWorkspaceOptions) (*tfe.RegistryNoCodeModuleWorkspace, error) { +func (m *MockRegistryNoCodeModules) UpgradeWorkspace(ctx context.Context, noCodeModuleID, workspaceID string, options *tfe.RegistryNoCodeModuleUpgradeWorkspaceOptions) (*tfe.Workspace, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpgradeWorkspace", ctx, noCodeModuleID, workspaceID, options) - ret0, _ := ret[0].(*tfe.RegistryNoCodeModuleWorkspace) + ret0, _ := ret[0].(*tfe.Workspace) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/registry_no_code_module.go b/registry_no_code_module.go index 0d29d756a..b1a021713 100644 --- a/registry_no_code_module.go +++ b/registry_no_code_module.go @@ -35,10 +35,10 @@ type RegistryNoCodeModules interface { Delete(ctx context.Context, ID string) error // CreateWorkspace creates a workspace using a no-code module. - CreateWorkspace(ctx context.Context, noCodeModuleID string, options *RegistryNoCodeModuleCreateWorkspaceOptions) (*RegistryNoCodeModuleWorkspace, error) + CreateWorkspace(ctx context.Context, noCodeModuleID string, options *RegistryNoCodeModuleCreateWorkspaceOptions) (*Workspace, error) // UpgradeWorkspace initiates an upgrade of an existing no-code module workspace. - UpgradeWorkspace(ctx context.Context, noCodeModuleID string, workspaceID string, options *RegistryNoCodeModuleUpgradeWorkspaceOptions) (*RegistryNoCodeModuleWorkspace, error) + UpgradeWorkspace(ctx context.Context, noCodeModuleID string, workspaceID string, options *RegistryNoCodeModuleUpgradeWorkspaceOptions) (*Workspace, error) } type RegistryNoCodeModuleCreateWorkspaceOptions struct { @@ -85,10 +85,6 @@ type RegistryNoCodeModuleUpgradeWorkspaceOptions struct { Variables []*Variable `jsonapi:"relation,vars,omitempty"` } -type RegistryNoCodeModuleWorkspace struct { - Workspace -} - // registryNoCodeModules implements RegistryNoCodeModules. type registryNoCodeModules struct { client *Client @@ -282,7 +278,7 @@ func (r *registryNoCodeModules) CreateWorkspace( ctx context.Context, noCodeModuleID string, options *RegistryNoCodeModuleCreateWorkspaceOptions, -) (*RegistryNoCodeModuleWorkspace, error) { +) (*Workspace, error) { if err := options.valid(); err != nil { return nil, err } @@ -293,7 +289,7 @@ func (r *registryNoCodeModules) CreateWorkspace( return nil, err } - w := &RegistryNoCodeModuleWorkspace{} + w := &Workspace{} err = req.Do(ctx, w) if err != nil { return nil, err @@ -308,7 +304,7 @@ func (r *registryNoCodeModules) UpgradeWorkspace( noCodeModuleID string, workspaceID string, options *RegistryNoCodeModuleUpgradeWorkspaceOptions, -) (*RegistryNoCodeModuleWorkspace, error) { +) (*Workspace, error) { if err := options.valid(); err != nil { return nil, err } @@ -322,7 +318,7 @@ func (r *registryNoCodeModules) UpgradeWorkspace( return nil, err } - w := &RegistryNoCodeModuleWorkspace{} + w := &Workspace{} err = req.Do(ctx, w) if err != nil { return nil, err diff --git a/registry_no_code_module_integration_test.go b/registry_no_code_module_integration_test.go index 0a68d994a..3ced0c2e4 100644 --- a/registry_no_code_module_integration_test.go +++ b/registry_no_code_module_integration_test.go @@ -355,7 +355,7 @@ func TestRegistryNoCodeModulesCreateWorkspace(t *testing.T) { wn := fmt.Sprintf("foo-%s", randomString(t)) sn := "my-app" su := "http://my-app.com" - _, err = client.RegistryNoCodeModules.CreateWorkspace( + w, err := client.RegistryNoCodeModules.CreateWorkspace( ctx, ncm.ID, &RegistryNoCodeModuleCreateWorkspaceOptions{ @@ -366,9 +366,6 @@ func TestRegistryNoCodeModulesCreateWorkspace(t *testing.T) { }, ) r.NoError(err) - - w, err := client.Workspaces.Read(ctx, org.Name, wn) - r.NoError(err) r.Equal(wn, w.Name) r.Equal(sn, w.SourceName) r.Equal(su, w.SourceURL) @@ -473,13 +470,15 @@ func TestRegistryNoCodeModuleWorkspaceUpgrade(t *testing.T) { r.NotNil(uncm) t.Run("test upgrading a workspace via a no-code module", func(t *testing.T) { - _, err = client.RegistryNoCodeModules.UpgradeWorkspace( + ws, err := client.RegistryNoCodeModules.UpgradeWorkspace( ctx, ncm.ID, w.ID, &RegistryNoCodeModuleUpgradeWorkspaceOptions{}, ) r.NoError(err) + r.NotNil(ws) + r.Equal(w.ID, ws.ID) }) t.Run("fail to upgrade workspace with invalid no-code module", func(t *testing.T) {