Skip to content

Commit

Permalink
Fixup tests and remove beta flag since feature is now released
Browse files Browse the repository at this point in the history
  • Loading branch information
rberecka committed Jul 31, 2023
1 parent d423935 commit 6d7d460
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Enhancements
* Added BETA support for including `projects` relationship and `projects-count` attribute to policy_set on create by @hs26gill [#737](https://github.com/hashicorp/go-tfe/pull/737)
* Added BETA method `AddProjects` and `RemoveProjects` for attaching/detaching policy set to projects by @Netra2104 [#735](https://github.com/hashicorp/go-tfe/pull/735)
* Added BETA support for adding and updating custom permissions to `TeamProjectAccesses`. A `TeamProjectAccessType` of `"custom"` can set various permissions applied at
* Added support for adding and updating custom permissions to `TeamProjectAccesses`. A `TeamProjectAccessType` of `"custom"` can set various permissions applied at
the project level to the project itself (`ProjectAccessOptions`) and all of the workspaces in a project (`WorkspaceAccessOptions`).[#745](https://github.com/hashicorp/go-tfe/pull/745)

# v1.30.0
Expand Down
10 changes: 5 additions & 5 deletions team_project_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ type WorkspaceAccessPermissionsOptions struct {
SentinelMocks *WorkspaceSentinelMocksPermissionType `json:"sentinel-mocks,omitempty"`
StateVersions *WorkspaceStateVersionsPermissionType `json:"state-versions,omitempty"`
Variables *WorkspaceVariablesPermissionType `json:"variables,omitempty"`
Create bool `json:"create,omitempty"`
Locking bool `json:"locking,omitempty"`
Move bool `json:"move,omitempty"`
Delete bool `json:"delete,omitempty"`
RunTasks bool `json:"run-tasks,omitempty"`
Create bool `json:"create"`
Locking bool `json:"locking"`
Move bool `json:"move"`
Delete bool `json:"delete"`
RunTasks bool `json:"run-tasks"`
}

// TeamProjectAccessListOptions represents the options for listing team project accesses
Expand Down
16 changes: 6 additions & 10 deletions team_project_access_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ func TestTeamProjectAccessesAdd(t *testing.T) {
})

t.Run("with valid options for all custom TeamProject permissions", func(t *testing.T) {
skipUnlessBeta(t)
options := TeamProjectAccessAddOptions{
Access: *ProjectAccess(TeamProjectAccessCustom),
Team: tmTest,
Expand Down Expand Up @@ -223,7 +222,6 @@ func TestTeamProjectAccessesAdd(t *testing.T) {
})

t.Run("with valid options for some custom TeamProject permissions", func(t *testing.T) {
skipUnlessBeta(t)
options := TeamProjectAccessAddOptions{
Access: *ProjectAccess(TeamProjectAccessCustom),
Team: tmTest,
Expand All @@ -237,12 +235,12 @@ func TestTeamProjectAccessesAdd(t *testing.T) {
}

tpa, err := client.TeamProjectAccess.Add(ctx, options)
defer func() {
t.Cleanup(func() {
err := client.TeamProjectAccess.Remove(ctx, tpa.ID)
if err != nil {
t.Logf("error removing team access (%s): %s", tpa.ID, err)
}
}()
})

require.NoError(t, err)

Expand Down Expand Up @@ -303,7 +301,6 @@ func TestTeamProjectAccessesAdd(t *testing.T) {
})

t.Run("when invalid custom project permission is provided in options", func(t *testing.T) {
skipUnlessBeta(t)
tpa, err := client.TeamProjectAccess.Add(ctx, TeamProjectAccessAddOptions{
Access: *ProjectAccess(TeamProjectAccessCustom),
Team: tmTest,
Expand Down Expand Up @@ -355,7 +352,6 @@ func TestTeamProjectAccessesUpdate(t *testing.T) {
})

t.Run("with valid custom permissions attributes for all permissions", func(t *testing.T) {
skipUnlessBeta(t)
options := TeamProjectAccessUpdateOptions{
Access: ProjectAccess(TeamProjectAccessCustom),
ProjectAccess: &ProjectAccessPermissionsOptions{
Expand All @@ -377,7 +373,8 @@ func TestTeamProjectAccessesUpdate(t *testing.T) {

tpa, err := client.TeamProjectAccess.Update(ctx, tpaTest.ID, options)
require.NoError(t, err)

require.NotNil(t, options.ProjectAccess)
require.NotNil(t, options.WorkspaceAccess)
assert.Equal(t, tpa.Access, TeamProjectAccessCustom)
assert.Equal(t, *options.ProjectAccess.Teams, tpa.ProjectAccess.ProjectTeamsPermission)
assert.Equal(t, *options.ProjectAccess.Settings, tpa.ProjectAccess.ProjectSettingsPermission)
Expand Down Expand Up @@ -407,7 +404,6 @@ func TestTeamProjectAccessesUpdate(t *testing.T) {
tpaCustomTest, err := client.TeamProjectAccess.Add(ctx, TpaOptions)
require.NoError(t, err)

skipUnlessBeta(t)
options := TeamProjectAccessUpdateOptions{
Access: ProjectAccess(TeamProjectAccessCustom),
ProjectAccess: &ProjectAccessPermissionsOptions{
Expand All @@ -420,7 +416,8 @@ func TestTeamProjectAccessesUpdate(t *testing.T) {

tpa, err := client.TeamProjectAccess.Update(ctx, tpaCustomTest.ID, options)
require.NoError(t, err)

require.NotNil(t, options.ProjectAccess)
require.NotNil(t, options.WorkspaceAccess)
assert.Equal(t, *options.ProjectAccess.Teams, tpa.ProjectAccess.ProjectTeamsPermission)
assert.Equal(t, false, tpa.WorkspaceAccess.WorkspaceCreatePermission)
// assert that other attributes remain the same
Expand All @@ -433,7 +430,6 @@ func TestTeamProjectAccessesUpdate(t *testing.T) {
assert.Equal(t, tpaCustomTest.WorkspaceAccess.WorkspaceStateVersionsPermission, tpa.WorkspaceAccess.WorkspaceStateVersionsPermission)
})
t.Run("with invalid custom permissions attributes", func(t *testing.T) {
skipUnlessBeta(t)
options := TeamProjectAccessUpdateOptions{
Access: ProjectAccess(TeamProjectAccessCustom),
ProjectAccess: &ProjectAccessPermissionsOptions{
Expand Down

0 comments on commit 6d7d460

Please sign in to comment.