Skip to content

Commit 3ee38f1

Browse files
committed
Some test structure reformatting
Signed-off-by: Timo Sand <[email protected]>
1 parent 8c39a7a commit 3ee38f1

1 file changed

Lines changed: 24 additions & 74 deletions

File tree

github/resource_github_repository_test.go

Lines changed: 24 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -431,20 +431,15 @@ func TestAccGithubRepository(t *testing.T) {
431431
}
432432
`, testRepoName, testAccConf.testPublicTemplateRepositoryOwner, testAccConf.testPublicTemplateRepository)
433433

434-
check := resource.ComposeTestCheckFunc(
435-
resource.TestCheckResourceAttr(
436-
"github_repository.test", "is_template",
437-
"false",
438-
),
439-
)
440-
441434
resource.Test(t, resource.TestCase{
442435
PreCheck: func() { skipUnauthenticated(t) },
443436
ProviderFactories: providerFactories,
444437
Steps: []resource.TestStep{
445438
{
446439
Config: config,
447-
Check: check,
440+
Check: resource.ComposeTestCheckFunc(
441+
resource.TestCheckResourceAttr("github_repository.test", "is_template", "false"),
442+
),
448443
},
449444
},
450445
})
@@ -466,20 +461,15 @@ func TestAccGithubRepository(t *testing.T) {
466461
}
467462
`, testRepoName, testAccConf.owner, testAccConf.testOrgTemplateRepository)
468463

469-
check := resource.ComposeTestCheckFunc(
470-
resource.TestCheckResourceAttr(
471-
"github_repository.test", "is_template",
472-
"false",
473-
),
474-
)
475-
476464
resource.Test(t, resource.TestCase{
477465
PreCheck: func() { skipUnlessHasOrgs(t) },
478466
ProviderFactories: providerFactories,
479467
Steps: []resource.TestStep{
480468
{
481469
Config: config,
482-
Check: check,
470+
Check: resource.ComposeTestCheckFunc(
471+
resource.TestCheckResourceAttr("github_repository.test", "is_template", "false"),
472+
),
483473
},
484474
},
485475
})
@@ -497,34 +487,23 @@ func TestAccGithubRepository(t *testing.T) {
497487
}
498488
`, testRepoName)
499489

500-
checks := map[string]resource.TestCheckFunc{
501-
"before": resource.ComposeTestCheckFunc(
502-
resource.TestCheckResourceAttr(
503-
"github_repository.test", "archived",
504-
"false",
505-
),
506-
),
507-
"after": resource.ComposeTestCheckFunc(
508-
resource.TestCheckResourceAttr(
509-
"github_repository.test", "archived",
510-
"true",
511-
),
512-
),
513-
}
514-
515490
resource.Test(t, resource.TestCase{
516491
PreCheck: func() { skipUnauthenticated(t) },
517492
ProviderFactories: providerFactories,
518493
Steps: []resource.TestStep{
519494
{
520495
Config: config,
521-
Check: checks["before"],
496+
Check: resource.ComposeTestCheckFunc(
497+
resource.TestCheckResourceAttr("github_repository.test", "archived", "false"),
498+
),
522499
},
523500
{
524501
Config: strings.Replace(config,
525502
`archived = false`,
526503
`archived = true`, 1),
527-
Check: checks["after"],
504+
Check: resource.ComposeTestCheckFunc(
505+
resource.TestCheckResourceAttr("github_repository.test", "archived", "true"),
506+
),
528507
},
529508
},
530509
})
@@ -697,40 +676,23 @@ resource "github_repository" "test" {
697676
`, testRepoName, updatedMergeCommitTitle, updatedMergeCommitMessage),
698677
}
699678

700-
checks := map[string]resource.TestCheckFunc{
701-
"before": resource.ComposeTestCheckFunc(
702-
resource.TestCheckResourceAttr(
703-
"github_repository.test", "merge_commit_title",
704-
mergeCommitTitle,
705-
),
706-
resource.TestCheckResourceAttr(
707-
"github_repository.test", "merge_commit_message",
708-
mergeCommitMessage,
709-
),
710-
),
711-
"after": resource.ComposeTestCheckFunc(
712-
resource.TestCheckResourceAttr(
713-
"github_repository.test", "merge_commit_title",
714-
updatedMergeCommitTitle,
715-
),
716-
resource.TestCheckResourceAttr(
717-
"github_repository.test", "merge_commit_message",
718-
updatedMergeCommitMessage,
719-
),
720-
),
721-
}
722-
723679
resource.Test(t, resource.TestCase{
724680
PreCheck: func() { skipUnauthenticated(t) },
725681
ProviderFactories: providerFactories,
726682
Steps: []resource.TestStep{
727683
{
728684
Config: configs["before"],
729-
Check: checks["before"],
685+
Check: resource.ComposeTestCheckFunc(
686+
resource.TestCheckResourceAttr("github_repository.test", "merge_commit_title", mergeCommitTitle),
687+
resource.TestCheckResourceAttr("github_repository.test", "merge_commit_message", mergeCommitMessage),
688+
),
730689
},
731690
{
732691
Config: configs["after"],
733-
Check: checks["after"],
692+
Check: resource.ComposeTestCheckFunc(
693+
resource.TestCheckResourceAttr("github_repository.test", "merge_commit_title", updatedMergeCommitTitle),
694+
resource.TestCheckResourceAttr("github_repository.test", "merge_commit_message", updatedMergeCommitMessage),
695+
),
734696
},
735697
},
736698
})
@@ -766,24 +728,12 @@ resource "github_repository" "test" {
766728

767729
checks := map[string]resource.TestCheckFunc{
768730
"before": resource.ComposeTestCheckFunc(
769-
resource.TestCheckResourceAttr(
770-
"github_repository.test", "squash_merge_commit_title",
771-
squashMergeCommitTitle,
772-
),
773-
resource.TestCheckResourceAttr(
774-
"github_repository.test", "squash_merge_commit_message",
775-
squashMergeCommitMessage,
776-
),
731+
resource.TestCheckResourceAttr("github_repository.test", "squash_merge_commit_title", squashMergeCommitTitle),
732+
resource.TestCheckResourceAttr("github_repository.test", "squash_merge_commit_message", squashMergeCommitMessage),
777733
),
778734
"after": resource.ComposeTestCheckFunc(
779-
resource.TestCheckResourceAttr(
780-
"github_repository.test", "squash_merge_commit_title",
781-
updatedSquashMergeCommitTitle,
782-
),
783-
resource.TestCheckResourceAttr(
784-
"github_repository.test", "squash_merge_commit_message",
785-
updatedSquashMergeCommitMessage,
786-
),
735+
resource.TestCheckResourceAttr("github_repository.test", "squash_merge_commit_title", updatedSquashMergeCommitTitle),
736+
resource.TestCheckResourceAttr("github_repository.test", "squash_merge_commit_message", updatedSquashMergeCommitMessage),
787737
),
788738
}
789739

0 commit comments

Comments
 (0)