Skip to content

Commit a268492

Browse files
committed
Fix TestGithubOrganizationRulesets/Creates_organization_ruleset_with_all_bypass_modes
Main fix: `bypass_actors` is returned as sorted from GH API so tests need re-indexing Signed-off-by: Timo Sand <[email protected]>
1 parent 59186e0 commit a268492

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

github/resource_github_organization_ruleset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
5050
Description: "Possible values for Enforcement are `disabled`, `active`, `evaluate`. Note: `evaluate` is currently only supported for owners of type `organization`.",
5151
},
5252
"bypass_actors": {
53-
Type: schema.TypeList,
53+
Type: schema.TypeList, // TODO: These are returned from GH API sorted by actor_id, we might want to investigate if we want to include sorting
5454
Optional: true,
5555
DiffSuppressFunc: bypassActorsDiffSuppressFunc,
5656
Description: "The actors that can bypass the rules in this ruleset.",

github/resource_github_organization_ruleset_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,9 @@ func TestGithubOrganizationRulesets(t *testing.T) {
315315
})
316316

317317
t.Run("Creates and updates organization using bypasses", func(t *testing.T) {
318+
resourceName := "test-creates-and-updates-using-bypasses"
318319
config := fmt.Sprintf(`
319-
resource "github_organization_ruleset" "test" {
320+
resource "github_organization_ruleset" "%s" {
320321
name = "test-%s"
321322
target = "branch"
322323
enforcement = "active"
@@ -356,6 +357,7 @@ func TestGithubOrganizationRulesets(t *testing.T) {
356357
required_linear_history = true
357358
required_signatures = false
358359
pull_request {
360+
allowed_merge_methods = ["merge", "squash", "rebase"]
359361
required_approving_review_count = 2
360362
required_review_thread_resolution = true
361363
require_code_owner_review = true
@@ -364,43 +366,43 @@ func TestGithubOrganizationRulesets(t *testing.T) {
364366
}
365367
}
366368
}
367-
`, randomID)
369+
`, resourceName, randomID)
368370

369371
check := resource.ComposeTestCheckFunc(
370372
resource.TestCheckResourceAttr(
371-
"github_organization_ruleset.test", "bypass_actors.#",
373+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.#",
372374
"3",
373375
),
374376
resource.TestCheckResourceAttr(
375-
"github_organization_ruleset.test", "bypass_actors.0.actor_type",
377+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.0.actor_type",
376378
"DeployKey",
377379
),
378380
resource.TestCheckResourceAttr(
379-
"github_organization_ruleset.test", "bypass_actors.0.bypass_mode",
381+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.0.bypass_mode",
380382
"always",
381383
),
382384
resource.TestCheckResourceAttr(
383-
"github_organization_ruleset.test", "bypass_actors.1.actor_id",
385+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.1.actor_id",
384386
"5",
385387
),
386388
resource.TestCheckResourceAttr(
387-
"github_organization_ruleset.test", "bypass_actors.1.actor_type",
389+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.1.actor_type",
388390
"RepositoryRole",
389391
),
390392
resource.TestCheckResourceAttr(
391-
"github_organization_ruleset.test", "bypass_actors.1.bypass_mode",
393+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.1.bypass_mode",
392394
"always",
393395
),
394396
resource.TestCheckResourceAttr(
395-
"github_organization_ruleset.test", "bypass_actors.2.actor_id",
397+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.2.actor_id",
396398
"1",
397399
),
398400
resource.TestCheckResourceAttr(
399-
"github_organization_ruleset.test", "bypass_actors.2.actor_type",
401+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.2.actor_type",
400402
"OrganizationAdmin",
401403
),
402404
resource.TestCheckResourceAttr(
403-
"github_organization_ruleset.test", "bypass_actors.2.bypass_mode",
405+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.2.bypass_mode",
404406
"always",
405407
),
406408
)

0 commit comments

Comments
 (0)