From 84b51a3623f971a56e7ee48f7debeb40204d1a3a Mon Sep 17 00:00:00 2001 From: James Sammut <70425486+james2791@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:20:58 +1000 Subject: [PATCH] SUP-2536: Asserting pipeline template datasource attributes on its tests (#559) * Asserting pipeline template datasource attributes on tests * [skip ci] Changelog amended with PR * PR title, lets get a status check --- CHANGELOG.md | 4 ++++ .../data_source_pipeline_template_test.go | 24 +++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87fe3750..3aabfd41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- SUP-2536: Asserting pipeline template datasource attributes on its tests [[PR #559](https://github.com/buildkite/terraform-provider-buildkite/pull/559)] @james2791 + ## [v1.10.2](https://github.com/buildkite/terraform-provider-buildkite/compare/v1.10.1...v1.10.2) - Adding a feature request template for better issue management/submission [[PR #549](https://github.com/buildkite/terraform-provider-buildkite/pull/549)] @mcncl diff --git a/buildkite/data_source_pipeline_template_test.go b/buildkite/data_source_pipeline_template_test.go index 0f283880..923c323a 100644 --- a/buildkite/data_source_pipeline_template_test.go +++ b/buildkite/data_source_pipeline_template_test.go @@ -27,7 +27,7 @@ func TestAccBuildkitePipelineTemplateDatasource(t *testing.T) { configuration = "steps:\n - label: \":pipeline:\"\n command: \"buildkite-agent pipeline upload\"" } - data "buildkite_pipeline_template" "data_template_foo" { + data "buildkite_pipeline_template" "template_foo" { depends_on = [buildkite_pipeline_template.template_foo] id = buildkite_pipeline_template.template_foo.id } @@ -50,7 +50,7 @@ func TestAccBuildkitePipelineTemplateDatasource(t *testing.T) { configuration = "steps:\n - label: \":pipeline:\"\n command: \"buildkite-agent pipeline upload\"" } - data "buildkite_pipeline_template" "data_template_bar" { + data "buildkite_pipeline_template" "template_bar" { depends_on = [buildkite_pipeline_template.template_bar] name = "Template %s" } @@ -73,7 +73,7 @@ func TestAccBuildkitePipelineTemplateDatasource(t *testing.T) { configuration = "steps:\n - label: \":pipeline:\"\n command: \"buildkite-agent pipeline upload\"" } - data "buildkite_pipeline_template" "data_template_bar" { + data "buildkite_pipeline_template" "template_bar" { depends_on = [buildkite_pipeline_template.template_bar] name = "Template %s" } @@ -96,7 +96,7 @@ func TestAccBuildkitePipelineTemplateDatasource(t *testing.T) { configuration = "steps:\n - label: \":pipeline:\"\n command: \"buildkite-agent pipeline upload\"" } - data "buildkite_pipeline_template" "data_template_bar" { + data "buildkite_pipeline_template" "template_bar" { depends_on = [buildkite_pipeline_template.template_bar] id = buildkite_pipeline_template.template_bar.id name = "Template %s" @@ -114,10 +114,10 @@ func TestAccBuildkitePipelineTemplateDatasource(t *testing.T) { // Confirm the pipeline template has the correct values in Buildkite's system testAccCheckPipelineTemplateRemoteValues(&ptr, fmt.Sprintf("Template %s", randName), false), // Check all pipeline template resource attributes are set in state (required attributes) - resource.TestCheckResourceAttrSet("buildkite_pipeline_template.template_foo", "id"), - resource.TestCheckResourceAttrSet("buildkite_pipeline_template.template_foo", "uuid"), - resource.TestCheckResourceAttrSet("buildkite_pipeline_template.template_foo", "name"), - resource.TestCheckResourceAttrSet("buildkite_pipeline_template.template_foo", "configuration"), + resource.TestCheckResourceAttrSet("data.buildkite_pipeline_template.template_foo", "id"), + resource.TestCheckResourceAttrSet("data.buildkite_pipeline_template.template_foo", "uuid"), + resource.TestCheckResourceAttrSet("data.buildkite_pipeline_template.template_foo", "name"), + resource.TestCheckResourceAttrSet("data.buildkite_pipeline_template.template_foo", "configuration"), ) resource.ParallelTest(t, resource.TestCase{ @@ -143,10 +143,10 @@ func TestAccBuildkitePipelineTemplateDatasource(t *testing.T) { // Confirm the pipeline template has the correct values in Buildkite's system testAccCheckPipelineTemplateRemoteValues(&ptr, fmt.Sprintf("Template %s", randName), false), // Check all pipeline template resource attributes are set in state (required attributes) - resource.TestCheckResourceAttrSet("buildkite_pipeline_template.template_bar", "id"), - resource.TestCheckResourceAttrSet("buildkite_pipeline_template.template_bar", "uuid"), - resource.TestCheckResourceAttrSet("buildkite_pipeline_template.template_bar", "name"), - resource.TestCheckResourceAttrSet("buildkite_pipeline_template.template_bar", "configuration"), + resource.TestCheckResourceAttrSet("data.buildkite_pipeline_template.template_bar", "id"), + resource.TestCheckResourceAttrSet("data.buildkite_pipeline_template.template_bar", "uuid"), + resource.TestCheckResourceAttrSet("data.buildkite_pipeline_template.template_bar", "name"), + resource.TestCheckResourceAttrSet("data.buildkite_pipeline_template.template_bar", "configuration"), ) resource.ParallelTest(t, resource.TestCase{