Skip to content

Commit

Permalink
Attempt to add data source test
Browse files Browse the repository at this point in the history
  • Loading branch information
briancain committed Feb 19, 2025
1 parent 4dc2645 commit cd2f8dc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
36 changes: 36 additions & 0 deletions internal/provider/waypoint/data_source_waypoint_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,35 @@ func TestAcc_Waypoint_Data_template_with_variable_options(t *testing.T) {
})
}

func TestAcc_Waypoint_Data_template_with_actions(t *testing.T) {
t.Parallel()

var (
appTemplateModel waypoint.TemplateResourceModel
actionCfgModel waypoint.ActionResourceModel
)
resourceName := "hcp_waypoint_template.actions_template_test"
actionResourceName := "hcp_waypoint_action.test"
// dataSourceName := "data." + resourceName
name := generateRandomName()

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
CheckDestroy: testAccCheckWaypointTemplateDestroy(t, &appTemplateModel),
Steps: []resource.TestStep{
{
// establish the base template
Config: testTemplateWithActionsConfig(name, actionResourceName),
Check: resource.ComposeTestCheckFunc(
testAccCheckWaypointTemplateExists(t, resourceName, &appTemplateModel),
testAccCheckWaypointActionExists(t, actionResourceName, &actionCfgModel),
),
},
},
})
}

func testDataAppTemplateConfig(name string) string {
return fmt.Sprintf(`%s
data "hcp_waypoint_template" "test" {
Expand All @@ -111,3 +140,10 @@ data "hcp_waypoint_template" "var_opts_test" {
name = hcp_waypoint_template.var_opts_test.name
}`, testTemplateConfigWithVarOpts(name))
}

func testDataAppTemplateWithAction(templateName, actionName string) string {
return fmt.Sprintf(`%s
data "hcp_waypoint_template" "action_test" {
name = hcp_waypoint_template.actions_template_test.name
}`, testTemplateWithActionsConfig(templateName, actionName))
}
2 changes: 0 additions & 2 deletions internal/provider/waypoint/resource_waypoint_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ func TestAcc_Waypoint_Create_Template_with_actions(t *testing.T) {
name := generateRandomName()
actionName := generateRandomName()

templateResourceStr := testTemplateWithActionsConfig(name, actionName)

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Expand Down

0 comments on commit cd2f8dc

Please sign in to comment.