@@ -40,6 +40,27 @@ func TestAccServiceAccount_basic(t *testing.T) {
4040 })
4141}
4242
43+ func TestAccServiceAccount_many (t * testing.T ) {
44+ testutils .CheckOSSTestsEnabled (t )
45+ testutils .CheckOSSTestsSemver (t , ">=9.1.0" )
46+
47+ name := acctest .RandString (10 )
48+
49+ resource .ParallelTest (t , resource.TestCase {
50+ ProviderFactories : testutils .ProviderFactories ,
51+ CheckDestroy : testAccServiceAccountCheckDestroy ,
52+ Steps : []resource.TestStep {
53+ {
54+ Config : testManyServiceAccountsConfig (name , 60 ),
55+ Check : resource .ComposeTestCheckFunc (
56+ resource .TestCheckResourceAttr ("grafana_service_account.test_1" , "name" , name + "-1" ),
57+ resource .TestCheckResourceAttr ("grafana_service_account.test_2" , "name" , name + "-2" ),
58+ ),
59+ },
60+ },
61+ })
62+ }
63+
4364func TestAccServiceAccount_invalid_role (t * testing.T ) {
4465 testutils .CheckOSSTestsEnabled (t )
4566
@@ -55,6 +76,22 @@ func TestAccServiceAccount_invalid_role(t *testing.T) {
5576 })
5677}
5778
79+ func testManyServiceAccountsConfig (prefix string , count int ) string {
80+ config := ``
81+
82+ for i := 0 ; i < count ; i ++ {
83+ config += fmt .Sprintf (`
84+ resource "grafana_service_account" "test_%[2]d" {
85+ name = "%[1]s-%[2]d"
86+ is_disabled = false
87+ role = "Viewer"
88+ }
89+ ` , prefix , i )
90+ }
91+
92+ return config
93+ }
94+
5895func testAccServiceAccountCheckExists (s * terraform.State ) error {
5996 return testAccServiceAccountCheckExistsBool (s , true )
6097}
0 commit comments