-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent_property_resource_test.go
More file actions
90 lines (87 loc) · 3.05 KB
/
component_property_resource_test.go
File metadata and controls
90 lines (87 loc) · 3.05 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package provider
import (
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccComponentPropertyResource(t *testing.T) {
resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and Read testing.
{
Config: providerConfig + `
resource "dependencytrack_project" "test" {
name = "Test_ComponentProperty"
}
resource "dependencytrack_component" "test" {
project = dependencytrack_project.test.id
name = "Test_ComponentProperty_Component"
version = "v1.0"
hashes = {}
}
resource "dependencytrack_component_property" "test" {
component = dependencytrack_component.test.id
group = "A"
name = "B"
value = "C"
type = "STRING"
description = "D"
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("dependencytrack_component_property.test", "id"),
resource.TestCheckResourceAttrPair(
"dependencytrack_component_property.test", "component",
"dependencytrack_component.test", "id",
),
resource.TestCheckResourceAttr("dependencytrack_component_property.test", "group", "A"),
resource.TestCheckResourceAttr("dependencytrack_component_property.test", "name", "B"),
resource.TestCheckResourceAttr("dependencytrack_component_property.test", "value", "C"),
resource.TestCheckResourceAttr("dependencytrack_component_property.test", "type", "STRING"),
resource.TestCheckResourceAttr("dependencytrack_component_property.test", "description", "D"),
),
},
// ImportState testing.
// TODO: Importing requires `id` and `component`. So would need to be custom constructed
/*{
ResourceName: "dependencytrack_component_property.test",
ImportState: true,
ImportStateVerify: true,
},*/
// Update and Read testing.
{
Config: providerConfig + `
resource "dependencytrack_project" "test" {
name = "Test_ComponentProperty"
}
resource "dependencytrack_component" "test" {
project = dependencytrack_project.test.id
name = "Test_ComponentProperty_Component"
version = "v1.0"
hashes = {}
}
resource "dependencytrack_component_property" "test" {
component = dependencytrack_component.test.id
group = "A"
name = "B"
value = "2"
type = "INTEGER"
description = "D"
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("dependencytrack_component_property.test", "id"),
resource.TestCheckResourceAttrPair(
"dependencytrack_component_property.test", "component",
"dependencytrack_component.test", "id",
),
resource.TestCheckResourceAttr("dependencytrack_component_property.test", "group", "A"),
resource.TestCheckResourceAttr("dependencytrack_component_property.test", "name", "B"),
resource.TestCheckResourceAttr("dependencytrack_component_property.test", "value", "2"),
resource.TestCheckResourceAttr("dependencytrack_component_property.test", "type", "INTEGER"),
resource.TestCheckResourceAttr("dependencytrack_component_property.test", "description", "D"),
),
},
},
})
}