...
1 package resource
2
3 import (
4 "strings"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8 )
9
10 func TestRef(t *testing.T) {
11 t.Parallel()
12 tcs := []struct {
13 title string
14 projectID string
15 location string
16 resourceType string
17 resourceName string
18 }{
19 {"Global", "project-id", "global", "resource-type", "resource-name"},
20 {"Non-Global", "project-id-2", "location-1234", "container-clusters", "resource-name-5635"},
21 }
22 for _, tc := range tcs {
23 tc := tc
24 t.Run(tc.title, func(t *testing.T) {
25 t.Parallel()
26 ref := Ref(tc.projectID, tc.location, tc.resourceType, tc.resourceName)
27 assert.NotEmpty(t, ref)
28 e := strings.Split(ref, "/")
29 if tc.location == Global {
30 assert.Equal(t, 5, len(e))
31 } else {
32 assert.Equal(t, 6, len(e))
33 }
34 })
35 }
36 }
37
View as plain text