forked from rework-space-com/terraform-provider-freeipa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource_hostgroup_test.go
73 lines (65 loc) · 1.96 KB
/
resource_hostgroup_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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAccFreeIPADNSHostgroup(t *testing.T) {
testHostgroup := map[string]string{
"name": "testhostgroup",
"description": "Host group test",
}
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccFreeIPADNSHostgroupResource_basic(testHostgroup),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("freeipa_hostgroup.hostgroup", "name", testHostgroup["name"]),
),
},
{
Config: testAccFreeIPADNSHostgroupResource_full(testHostgroup),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("freeipa_hostgroup.hostgroup", "name", testHostgroup["name"]),
resource.TestCheckResourceAttr("freeipa_hostgroup.hostgroup", "description", testHostgroup["description"]),
),
},
},
})
}
func testAccFreeIPADNSHostgroupResource_basic(dataset map[string]string) string {
provider_host := os.Getenv("FREEIPA_HOST")
provider_user := os.Getenv("FREEIPA_USERNAME")
provider_pass := os.Getenv("FREEIPA_PASSWORD")
return fmt.Sprintf(`
provider "freeipa" {
host = "%s"
username = "%s"
password = "%s"
insecure = true
}
resource "freeipa_hostgroup" "hostgroup" {
name = "%s"
}
`, provider_host, provider_user, provider_pass, dataset["name"])
}
func testAccFreeIPADNSHostgroupResource_full(dataset map[string]string) string {
provider_host := os.Getenv("FREEIPA_HOST")
provider_user := os.Getenv("FREEIPA_USERNAME")
provider_pass := os.Getenv("FREEIPA_PASSWORD")
return fmt.Sprintf(`
provider "freeipa" {
host = "%s"
username = "%s"
password = "%s"
insecure = true
}
resource "freeipa_hostgroup" "hostgroup" {
name = "%s"
description = "%s"
}
`, provider_host, provider_user, provider_pass, dataset["name"], dataset["description"])
}