package resource import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestRef(t *testing.T) { t.Parallel() tcs := []struct { title string projectID string location string resourceType string resourceName string }{ {"Global", "project-id", "global", "resource-type", "resource-name"}, {"Non-Global", "project-id-2", "location-1234", "container-clusters", "resource-name-5635"}, } for _, tc := range tcs { tc := tc t.Run(tc.title, func(t *testing.T) { t.Parallel() ref := Ref(tc.projectID, tc.location, tc.resourceType, tc.resourceName) assert.NotEmpty(t, ref) e := strings.Split(ref, "/") if tc.location == Global { assert.Equal(t, 5, len(e)) } else { assert.Equal(t, 6, len(e)) } }) } }