Skip to content

Commit

Permalink
test: get language from sonarqube_project
Browse files Browse the repository at this point in the history
  • Loading branch information
david-ortiz-saez committed Oct 31, 2023
1 parent d7dd453 commit 12ec42a
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
})
}

0 comments on commit 12ec42a

Please sign in to comment.