Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
- Wrong separator in tests
- Allow pointers
  • Loading branch information
julienduchesne committed Mar 2, 2024
1 parent 8132ea2 commit cb26648
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions internal/common/resource_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package common

import (
"fmt"
"reflect"
"strconv"
"strings"
)
Expand Down Expand Up @@ -66,6 +67,10 @@ func (id *ResourceID) Make(parts ...any) string {
}
stringParts := make([]string, len(parts))
for i, part := range parts {
// Unwrap pointers
if reflect.ValueOf(part).Kind() == reflect.Ptr {
part = reflect.ValueOf(part).Elem().Interface()
}
expectedField := id.expectedFields[i]
switch expectedField.Type {
case ResourceIDFieldTypeInt:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func testAccCloudAccessPolicyCheckExists(rn string, a *gcom.AuthAccessPolicy) re
return fmt.Errorf("resource id not set")
}

region, id, _ := strings.Cut(rs.Primary.ID, "/")
region, id, _ := strings.Cut(rs.Primary.ID, ":")

client := testutils.Provider.Meta().(*common.Client).GrafanaCloudAPI
policy, _, err := client.AccesspoliciesAPI.GetAccessPolicy(context.Background(), id).Region(region).Execute()
Expand All @@ -179,7 +179,7 @@ func testAccCloudAccessPolicyTokenCheckExists(rn string, a *gcom.AuthToken) reso
return fmt.Errorf("resource id not set")
}

region, id, _ := strings.Cut(rs.Primary.ID, "/")
region, id, _ := strings.Cut(rs.Primary.ID, ":")

client := testutils.Provider.Meta().(*common.Client).GrafanaCloudAPI
token, _, err := client.TokensAPI.GetToken(context.Background(), id).Region(region).Execute()
Expand Down

0 comments on commit cb26648

Please sign in to comment.