-
Notifications
You must be signed in to change notification settings - Fork 16
/
resource_transip_openstack_user_test.go
65 lines (57 loc) · 1.62 KB
/
resource_transip_openstack_user_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
package main
import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/sethvargo/go-password/password"
"os"
"testing"
)
func TestAccTransipResourcOpenstackUser(t *testing.T) {
if os.Getenv("THIS_IS_GOING_TO_COST_ME_MONEY") == "" {
t.Skip("THIS_IS_GOING_TO_COST_ME_MONEY not set, skipping")
}
openstackProjectId := os.Getenv("TF_VAR_openstack_project_id")
if openstackProjectId == "" {
t.Skip("TF_VAR_openstack_project_id not provided, skipping")
}
pwd, err := password.Generate(8, 1, 1, false, false)
if err != nil {
t.Skip("failed to generate password", err)
}
testConfig := fmt.Sprintf(`
resource "transip_openstack_user" "test" {
projectid = "%s"
username = "tf-test-user"
email = "[email protected]"
password = "%s"
description = "terraform test user"
}
`, openstackProjectId, pwd)
testConfigUpdate := fmt.Sprintf(`
resource "transip_openstack_user" "test" {
projectid = "%s"
username = "tf-test-user"
email = "[email protected]"
password = "%s"
description = "terraform test user"
}
`, openstackProjectId, pwd)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("transip_openstack_user", "username", "tf-test-user"),
),
},
{
Config: testConfigUpdate,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("transip_openstack_user", "email", "[email protected]"),
),
},
},
})
}