generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhelpers_test.go
31 lines (27 loc) · 974 Bytes
/
helpers_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
package client
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/stretchr/testify/assert"
"testing"
)
func TestIsKeyExluded(t *testing.T) {
assert.Equal(t, true, isKeyExluded("key", []string{"key", "other-key"}))
assert.Equal(t, false, isKeyExluded("key", []string{"key1", "key2"}))
}
func TestResourceTypeSetToStringSlice(t *testing.T) {
s := &schema.Set{F: schema.HashString}
for _, i := range []string{"element1", "element2", "element3"} {
s.Add(i)
}
assert.Contains(t, ResourceTypeSetToStringSlice(s), "element1")
assert.Contains(t, ResourceTypeSetToStringSlice(s), "element2")
assert.Contains(t, ResourceTypeSetToStringSlice(s), "element3")
}
func TestConvertTagsListToMap(t *testing.T) {
tags := []Tag{{"tag-name-1", "tag-value-1"}, {"tag-name-2", "tag-value-2"}}
expected := map[string]string{
"tag-name-1": "tag-value-1",
"tag-name-2": "tag-value-2",
}
assert.Equal(t, expected, ConvertTagsListToMap(tags))
}