-
Notifications
You must be signed in to change notification settings - Fork 4
/
resource_test.go
39 lines (31 loc) · 954 Bytes
/
resource_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package limacharlie
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestResourceAddDelete(t *testing.T) {
a := assert.New(t)
org := getTestOrgFromEnv(a)
resourcesBase, err := org.Resources()
a.NoError(err)
resourceName := "ip-geo"
resourceCategory := ResourceCategories.API
err = org.ResourceSubscribe(resourceName, resourceCategory)
a.NoError(err)
time.Sleep(5 * time.Second)
resources, err := org.Resources()
a.NoError(err)
expectedResources := resourcesBase.duplicate()
apiResources := expectedResources.GetForCategory(ResourceCategories.API)
apiResources["ip-geo"] = struct{}{}
expectedResources[ResourceCategories.API] = apiResources
a.Equal(expectedResources, resources)
err = org.ResourceUnsubscribe(resourceName, resourceCategory)
a.NoError(err)
delete(apiResources, "ip-geo")
time.Sleep(15 * time.Second)
resources, err = org.Resources()
a.NoError(err)
a.Equal(resourcesBase, resources)
}