Skip to content

Commit

Permalink
Merge pull request #23 from form3tech-oss/fmatavelli-fix-pool
Browse files Browse the repository at this point in the history
Type and tests fixes to drp_pool
  • Loading branch information
fabiomatavelli-f3 authored Aug 30, 2023
2 parents 068663e + e569f58 commit 906ab35
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
tf_version: ["0.13", "0.14", "0.15", "1.0", "1.1", "1.2", "1.3", "1.4"]
tf_version: ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5"]
needs: setup-drp
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion drpv4/resource_drp_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func resourcePool() *schema.Resource {
Optional: true,
Description: "The pool add parameters.",
Elem: &schema.Schema{
Type: schema.TypeMap,
Type: schema.TypeString,
},
},
"add_profiles": {
Expand Down
57 changes: 55 additions & 2 deletions drpv4/resource_drp_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestAccResourcePool(t *testing.T) {
resource.TestCheckResourceAttr("drp_pool.test", "autofill.#", "1"),
resource.TestCheckResourceAttr("drp_pool.test", "autofill.0.max_free", "1"),
),
ExpectNonEmptyPlan: true,
ExpectNonEmptyPlan: false,
},
{
Config: fmt.Sprintf(`
Expand Down Expand Up @@ -153,7 +153,60 @@ func TestAccResourcePool(t *testing.T) {
resource.TestCheckResourceAttr("drp_pool.test", "autofill.#", "1"),
resource.TestCheckResourceAttr("drp_pool.test", "autofill.0.max_free", "1"),
),
ExpectNonEmptyPlan: true,
ExpectNonEmptyPlan: false,
},
{
Config: fmt.Sprintf(`
resource "drp_stage" "test" {
name = "%s"
template {
name = "test"
contents = <<-EOF
#!/bin/bash
echo "test"
EOF
path = "/tmp/test"
}
}
resource "drp_workflow" "test" {
name = "%s"
description = "test"
stages = [drp_stage.test.name]
}
resource "drp_pool" "test-param" {
pool_id = "%s-param"
description = "test pool"
documentation = "test pool"
allocate_actions {
workflow = drp_workflow.test.name
remove_parameters = ["test"]
add_parameters = {
"universal/application" = "image-deploy"
}
}
release_actions {
workflow = drp_workflow.test.name
add_parameters = {
"universal/application" = "hw-only"
}
}
}
`, testPoolRandomName, testPoolRandomName, testPoolRandomName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("drp_pool.test-param", "allocate_actions.#", "1"),
resource.TestCheckResourceAttr("drp_pool.test-param", "allocate_actions.0.workflow", testPoolRandomName),
resource.TestCheckResourceAttr("drp_pool.test-param", "allocate_actions.0.add_parameters.%", "1"),
resource.TestCheckResourceAttr("drp_pool.test-param", `allocate_actions.0.add_parameters.universal/application`, "image-deploy"),
resource.TestCheckResourceAttr("drp_pool.test-param", "release_actions.#", "1"),
resource.TestCheckResourceAttr("drp_pool.test-param", "release_actions.0.add_parameters.%", "1"),
resource.TestCheckResourceAttr("drp_pool.test-param", `release_actions.0.add_parameters.universal/application`, "hw-only"),
),
ExpectNonEmptyPlan: false,
},
},
})
Expand Down
10 changes: 5 additions & 5 deletions drpv4/resource_drp_reservation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestAccResourceReservation(t *testing.T) {
description = "test reservation"
documentation = "test reservation"
duration = 86400
token = "test"
token = "ff:70:81:a9:78:4d"
subnet = "255.255.255.0"
}
`,
Expand All @@ -28,7 +28,7 @@ func TestAccResourceReservation(t *testing.T) {
resource.TestCheckResourceAttr("drp_reservation.test", "description", "test reservation"),
resource.TestCheckResourceAttr("drp_reservation.test", "documentation", "test reservation"),
resource.TestCheckResourceAttr("drp_reservation.test", "duration", "86400"),
resource.TestCheckResourceAttr("drp_reservation.test", "token", "test"),
resource.TestCheckResourceAttr("drp_reservation.test", "token", "ff:70:81:a9:78:4d"),
resource.TestCheckResourceAttr("drp_reservation.test", "subnet", "255.255.255.0"),
),
},
Expand All @@ -39,7 +39,7 @@ func TestAccResourceReservation(t *testing.T) {
description = "test reservation"
documentation = "test reservation"
duration = 86400
token = "test"
token = "ff:70:81:a9:78:4d"
next_server = "192.168.1.1"
subnet = "255.255.255.0"
Expand All @@ -60,7 +60,7 @@ func TestAccResourceReservation(t *testing.T) {
description = "test reservation"
documentation = "test reservation"
duration = 86400
token = "test"
token = "ff:70:81:a9:78:4d"
subnet = "255.255.255.0"
}
`,
Expand All @@ -75,7 +75,7 @@ func TestAccResourceReservation(t *testing.T) {
description = "test reservation"
documentation = "test reservation"
duration = 86400
token = "test"
token = "ff:70:81:a9:78:4d"
subnet = "255.255.255.0"
}
`,
Expand Down
1 change: 1 addition & 0 deletions drpv4/resource_drp_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func resourceStage() *schema.Resource {
Type: schema.TypeBool,
Description: "Stage runner wait",
Optional: true,
Computed: true,
},
"tasks": {
Type: schema.TypeList,
Expand Down
3 changes: 0 additions & 3 deletions drpv4/resource_drp_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestAccWorkflowResource(t *testing.T) {
resource.TestCheckResourceAttr("drp_workflow.test", "stages.#", "1"),
resource.TestCheckResourceAttr("drp_workflow.test", "stages.0", testWorkflowRandomName),
),
ExpectNonEmptyPlan: true,
},
{
Config: fmt.Sprintf(`
Expand Down Expand Up @@ -69,7 +68,6 @@ func TestAccWorkflowResource(t *testing.T) {
resource.TestCheckResourceAttr("drp_workflow.test", "stages.#", "1"),
resource.TestCheckResourceAttr("drp_workflow.test", "stages.0", testWorkflowRandomName),
),
ExpectNonEmptyPlan: true,
},
{
Config: fmt.Sprintf(`
Expand Down Expand Up @@ -97,7 +95,6 @@ func TestAccWorkflowResource(t *testing.T) {
resource.TestCheckResourceAttr("drp_workflow.test", "stages.#", "1"),
resource.TestCheckResourceAttr("drp_workflow.test", "stages.0", testWorkflowRandomName),
),
ExpectNonEmptyPlan: true,
},
},
})
Expand Down

0 comments on commit 906ab35

Please sign in to comment.