-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathresource_variable_test.go
More file actions
51 lines (46 loc) · 1.32 KB
/
resource_variable_test.go
File metadata and controls
51 lines (46 loc) · 1.32 KB
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
package main
import (
"fmt"
"strings"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAcc_Variable(t *testing.T) {
value1 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
value2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
key := "test_key"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: providers(),
Steps: []resource.TestStep{
{
Config: variableConfig(value1, key),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("airflow_variable.test", "value", value1),
resource.TestCheckResourceAttr("airflow_variable.test", "key", key),
),
},
{
Config: variableConfig(value2, key),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("airflow_variable.test", "value", value2),
resource.TestCheckResourceAttr("airflow_variable.test", "key", key),
),
},
{
ResourceName: "airflow_variable.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func variableConfig(value, key string) string {
return fmt.Sprintf(`
resource "airflow_variable" "test" {
value = "%s"
key = "%s"
}
`, value, key)
}