Skip to content

Commit

Permalink
Fix Acceptance tests
Browse files Browse the repository at this point in the history
Add timeout and success_on_empty_node_filter to attributes set to the
job based on job data (jobToResourceData function)

Fix TestOchestrator_high_low and TestOchestrator_max_percent (wrong job
name in the expected/actual test)

Fix testAccJobOptions_secure_options (shouldn't expect an error, should
just check that the right option on the job has been set)
  • Loading branch information
andrea-berling committed Jun 26, 2024
1 parent b257942 commit df87b1a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rundeck/import_resource_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccRundeckJob_Import(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions rundeck/resource_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,9 @@ func jobToResourceData(job *JobDetail, d *schema.ResourceData) error {
if err := d.Set("allow_concurrent_executions", job.AllowConcurrentExecutions); err != nil {
return err
}
if err := d.Set("timeout", job.Timeout); err != nil {
return err
}
if job.Retry != nil {
if err := d.Set("retry", job.Retry.Value); err != nil {
return err
Expand All @@ -949,6 +952,9 @@ func jobToResourceData(job *JobDetail, d *schema.ResourceData) error {
if err := d.Set("rank_order", job.Dispatch.RankOrder); err != nil {
return err
}
if err := d.Set("success_on_empty_node_filter", job.Dispatch.SuccessOnEmptyNodeFilter); err != nil {
return err
}
} else {
if err := d.Set("max_thread_count", 1); err != nil {
return err
Expand Down
23 changes: 19 additions & 4 deletions rundeck/resource_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestOchestrator_high_low(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccJobCheckExists("rundeck_job.test", &job),
func(s *terraform.State) error {
if expected := "basic-job-with-node-filter"; job.Name != expected {
if expected := "orchestrator-High-Low"; job.Name != expected {
return fmt.Errorf("wrong name; expected %v, got %v", expected, job.Name)
}
if expected := "name: tacobell"; job.CommandSequence.Commands[0].Job.NodeFilter.Query != expected {
Expand All @@ -110,7 +110,7 @@ func TestOchestrator_max_percent(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccJobCheckExists("rundeck_job.test", &job),
func(s *terraform.State) error {
if expected := "basic-job-with-node-filter"; job.Name != expected {
if expected := "orchestrator-MaxPercent"; job.Name != expected {
return fmt.Errorf("wrong name; expected %v, got %v", expected, job.Name)
}
if expected := "name: tacobell"; job.CommandSequence.Commands[0].Job.NodeFilter.Query != expected {
Expand Down Expand Up @@ -261,8 +261,23 @@ func TestAccJobOptions_secure_choice(t *testing.T) {
CheckDestroy: testAccJobCheckDestroy(&job),
Steps: []resource.TestStep{
{
Config: testAccJobOptions_secure_options,
ExpectError: regexp.MustCompile("argument \"value_choices\" can not have empty values; try \"required\""),
Config: testAccJobOptions_secure_options,
Check: resource.ComposeTestCheckFunc(
testAccJobCheckExists("rundeck_job.test", &job),
func(s *terraform.State) error {
secureOption := job.OptionsConfig.Options[0]
if expected := "foo_secure"; secureOption.Name != expected {
return fmt.Errorf("wrong name; expected %v, got %v", expected, secureOption.Name)
}
if expected := "/keys/test/path/"; secureOption.StoragePath != expected {
return fmt.Errorf("wrong storage_path; expected %v, got %v", expected, secureOption.Name)
}
if expected := true; secureOption.ObscureInput != expected {
return fmt.Errorf("failed to set the input as obscure; expected %v, got %v", expected, secureOption.ObscureInput)
}
return nil
},
),
},
},
})
Expand Down

0 comments on commit df87b1a

Please sign in to comment.