Skip to content

Commit

Permalink
Test the resource too
Browse files Browse the repository at this point in the history
  • Loading branch information
renaudhartert-db committed Dec 27, 2024
1 parent a79e9ef commit 1cf38c5
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions permissions/resource_permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,36 @@ func TestResourcePermissionsRead_EmptyListResultsInRemoval(t *testing.T) {
}.ApplyNoError(t)
}

func TestResourcePermissionsRead_EmptyListResultsInRemovalWith504Errors(t *testing.T) {
qa.ResourceFixture{
MockWorkspaceClientFunc: func(mwc *mocks.MockWorkspaceClient) {
mwc.GetMockCurrentUserAPI().EXPECT().Me(mock.Anything).Return(&iam.User{UserName: "admin"}, nil)

req := iam.GetPermissionRequest{
RequestObjectId: "abc",
RequestObjectType: "clusters",
}

// Fail 3 times with a 504 error. These should be retried
// transparently.
call := mwc.GetMockPermissionsAPI().EXPECT().Get(mock.Anything, req).Return(nil, apierr.ErrDeadlineExceeded)
call.Repeatability = 3

mwc.GetMockPermissionsAPI().EXPECT().Get(mock.Anything, req).Return(&iam.ObjectPermissions{
ObjectId: "/clusters/abc",
ObjectType: "cluster",
}, nil)
},
Resource: ResourcePermissions(),
Read: true,
Removed: true,
InstanceState: map[string]string{
"cluster_id": "abc",
},
ID: "/clusters/abc",
}.ApplyNoError(t)
}

func TestResourcePermissionsDelete(t *testing.T) {
d, err := qa.ResourceFixture{
MockWorkspaceClientFunc: func(mwc *mocks.MockWorkspaceClient) {
Expand Down

0 comments on commit 1cf38c5

Please sign in to comment.