Skip to content

Commit 4808483

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 74bcfe7 commit 4808483

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
@@ -46,7 +46,7 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
4646
Description: "Possible values for Enforcement are `disabled`, `active`, `evaluate`. Note: `evaluate` is currently only supported for owners of type `organization`.",
4747
},
4848
"bypass_actors": {
49-
Type: schema.TypeList,
49+
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
5050
Optional: true,
5151
DiffSuppressFunc: bypassActorsDiffSuppressFunc,
5252
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
@@ -322,8 +322,9 @@ func TestGithubOrganizationRulesets(t *testing.T) {
322322
})
323323

324324
t.Run("Creates and updates organization using bypasses", func(t *testing.T) {
325+
resourceName := "test-creates-and-updates-using-bypasses"
325326
config := fmt.Sprintf(`
326-
resource "github_organization_ruleset" "test" {
327+
resource "github_organization_ruleset" "%s" {
327328
name = "test-%s"
328329
target = "branch"
329330
enforcement = "active"
@@ -363,6 +364,7 @@ func TestGithubOrganizationRulesets(t *testing.T) {
363364
required_linear_history = true
364365
required_signatures = false
365366
pull_request {
367+
allowed_merge_methods = ["merge", "squash", "rebase"]
366368
required_approving_review_count = 2
367369
required_review_thread_resolution = true
368370
require_code_owner_review = true
@@ -371,43 +373,43 @@ func TestGithubOrganizationRulesets(t *testing.T) {
371373
}
372374
}
373375
}
374-
`, randomID)
376+
`, resourceName, randomID)
375377

376378
check := resource.ComposeTestCheckFunc(
377379
resource.TestCheckResourceAttr(
378-
"github_organization_ruleset.test", "bypass_actors.#",
380+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.#",
379381
"3",
380382
),
381383
resource.TestCheckResourceAttr(
382-
"github_organization_ruleset.test", "bypass_actors.0.actor_type",
384+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.0.actor_type",
383385
"DeployKey",
384386
),
385387
resource.TestCheckResourceAttr(
386-
"github_organization_ruleset.test", "bypass_actors.0.bypass_mode",
388+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.0.bypass_mode",
387389
"always",
388390
),
389391
resource.TestCheckResourceAttr(
390-
"github_organization_ruleset.test", "bypass_actors.1.actor_id",
392+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.1.actor_id",
391393
"5",
392394
),
393395
resource.TestCheckResourceAttr(
394-
"github_organization_ruleset.test", "bypass_actors.1.actor_type",
396+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.1.actor_type",
395397
"RepositoryRole",
396398
),
397399
resource.TestCheckResourceAttr(
398-
"github_organization_ruleset.test", "bypass_actors.1.bypass_mode",
400+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.1.bypass_mode",
399401
"always",
400402
),
401403
resource.TestCheckResourceAttr(
402-
"github_organization_ruleset.test", "bypass_actors.2.actor_id",
404+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.2.actor_id",
403405
"1",
404406
),
405407
resource.TestCheckResourceAttr(
406-
"github_organization_ruleset.test", "bypass_actors.2.actor_type",
408+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.2.actor_type",
407409
"OrganizationAdmin",
408410
),
409411
resource.TestCheckResourceAttr(
410-
"github_organization_ruleset.test", "bypass_actors.2.bypass_mode",
412+
fmt.Sprintf("github_organization_ruleset.%s", resourceName), "bypass_actors.2.bypass_mode",
411413
"always",
412414
),
413415
)

0 commit comments

Comments
 (0)