-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathresource_transip_vps_test.go
72 lines (64 loc) · 1.62 KB
/
resource_transip_vps_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
package main
import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"time"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"os"
"testing"
)
func TestAccTransipResourceVpsImport(t *testing.T) {
vpsName := os.Getenv("TF_VAR_vps_name")
if vpsName == "" {
t.Skip("TF_VAR_vps_name not provided, skipping")
}
testConfig := fmt.Sprintf(`
resource "transip_vps" "test" {
product_name = "vps-bladevps-x2"
operating_system = "Debian 6"
}
`)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testConfig,
ResourceName: "transip_vps.test",
ImportState: true,
ImportStateId: vpsName,
ImportStateCheck: func(s []*terraform.InstanceState) error {
if s[0].ID != vpsName {
return fmt.Errorf("import failed")
}
return nil
},
},
},
})
}
func TestAccTransipResourceVps(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")
}
timestamp := time.Now().Unix()
testConfig := fmt.Sprintf(`
resource "transip_vps" "test" {
description = "test-%d"
product_name = "vps-bladevps-x2"
operating_system = "ubuntu-20.04"
}
`, timestamp)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("transip_vps.test", "status", "running"),
),
},
},
})
}