Copilot commented on code in PR #300:
URL: 
https://github.com/apache/cloudstack-terraform-provider/pull/300#discussion_r3557494651


##########
cloudstack/resource_cloudstack_role_permission_test.go:
##########
@@ -0,0 +1,152 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package cloudstack
+
+import (
+       "fmt"
+       "testing"
+
+       "github.com/apache/cloudstack-go/v2/cloudstack"
+       "github.com/hashicorp/terraform-plugin-testing/helper/resource"
+       "github.com/hashicorp/terraform-plugin-testing/terraform"
+)
+
+func TestAccCloudStackRolePermission_basic(t *testing.T) {
+       var rolePermission cloudstack.RolePermission
+
+       resource.Test(t, resource.TestCase{
+               PreCheck:     func() { testAccPreCheck(t) },
+               Providers:    testAccProviders,
+               CheckDestroy: testAccCheckCloudStackRolePermissionDestroy,
+               Steps: []resource.TestStep{
+                       {
+                               Config: testAccCloudStackRolePermission_basic,
+                               Check: resource.ComposeTestCheckFunc(
+                                       
testAccCheckCloudStackRolePermissionExists("cloudstack_role_permission.foo", 
&rolePermission),
+                                       resource.TestCheckResourceAttr(
+                                               
"cloudstack_role_permission.foo", "rule", "listVirtualMachines"),
+                                       resource.TestCheckResourceAttr(
+                                               
"cloudstack_role_permission.foo", "permission", "allow"),
+                                       resource.TestCheckResourceAttr(
+                                               
"cloudstack_role_permission.foo", "description", "terraform test role 
permission"),
+                               ),
+                       },
+                       {
+                               Config: testAccCloudStackRolePermission_update,
+                               Check: resource.ComposeTestCheckFunc(
+                                       
testAccCheckCloudStackRolePermissionExists("cloudstack_role_permission.foo", 
&rolePermission),
+                                       resource.TestCheckResourceAttr(
+                                               
"cloudstack_role_permission.foo", "permission", "deny"),
+                               ),
+                       },

Review Comment:
   The update step only asserts that `permission` becomes `deny`, but it 
doesn’t verify the PR’s key promise that allow/deny can be toggled *in-place* 
(i.e., without recreating the role permission). Add a check that the resource 
ID stays the same across the update step to catch accidental ForceNew/recreate 
regressions.



##########
cloudstack/provider.go:
##########
@@ -162,6 +162,7 @@ func Provider() *schema.Provider {
                        "cloudstack_domain":                         
resourceCloudStackDomain(),
                        "cloudstack_network_service_provider":       
resourceCloudStackNetworkServiceProvider(),
                        "cloudstack_role":                           
resourceCloudStackRole(),
+                       "cloudstack_role_permission":                
resourceCloudStackRolePermission(),

Review Comment:
   The PR description says it creates a `cloudstack_role_permissions` resource 
(plural), but the implementation adds `cloudstack_role_permission` (singular). 
Please update the PR description (or rename if the plural form was intended) to 
avoid confusing users/searchability in changelogs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to