From 12ec42abe52810bd0d9be6c7e661ff8f925855f6 Mon Sep 17 00:00:00 2001 From: david-ortiz Date: Tue, 31 Oct 2023 15:47:26 +0100 Subject: [PATCH] test: get language from sonarqube_project --- ...qualityprofile_project_association_test.go | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/sonarqube/resource_sonarqube_qualityprofile_project_association_test.go b/sonarqube/resource_sonarqube_qualityprofile_project_association_test.go index 8a69c552..f24d32c3 100644 --- a/sonarqube/resource_sonarqube_qualityprofile_project_association_test.go +++ b/sonarqube/resource_sonarqube_qualityprofile_project_association_test.go @@ -112,3 +112,48 @@ func TestAccSonarqubeQualityProfileProjectAssociationSonarWay(t *testing.T) { }, }) } + +func testAccSonarqubeQualityProfileProjectAssociationSonarWayGetLanguage(rnd string, name string, language string) string { + return fmt.Sprintf(` + resource "sonarqube_project" "%[1]s" { + name = "%[2]s" + project = "%[2]s" + visibility = "public" + } + + resource "sonarqube_qualityprofile_project_association" "%[1]s" { + quality_profile = "Sonar way" + project = sonarqube_project.%[1]s.name + language = sonarqube_project.%[1]s.language + }`, rnd, name, language) +} + +func TestAccSonarqubeQualityProfileProjectAssociationSonarWayGetLanguage(t *testing.T) { + rnd := generateRandomResourceName() + name := "sonarqube_qualityprofile_project_association." + rnd + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccSonarqubeQualityProfileProjectAssociationSonarWayGetLanguage(rnd, "testAccSonarqubeProfileProjectAssociation", "js"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(name, "quality_profile", "Sonar way"), + resource.TestCheckResourceAttr(name, "project", "testAccSonarqubeProfileProjectAssociation"), + resource.TestCheckResourceAttr(name, "language", "js"), + ), + }, + { + ResourceName: name, + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(name, "quality_profile", "Sonar way"), + resource.TestCheckResourceAttr(name, "project", "testAccSonarqubeProfileProjectAssociation"), + resource.TestCheckResourceAttr(name, "language", "js"), + ), + }, + }, + }) +}