Skip to content

Commit 9c19fc9

Browse files
authored
Merge pull request #643 from gitlabhq/mattkasa-fix-default-branch-name
fix: update default branch name to "main"
2 parents 51b569d + becd681 commit 9c19fc9

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

gitlab/resource_gitlab_project_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type testAccGitlabProjectExpectedAttributes struct {
1818
}
1919

2020
func TestAccGitlabProject_basic(t *testing.T) {
21-
var received, defaults, defaultsMasterBranch gitlab.Project
21+
var received, defaults, defaultsMainBranch gitlab.Project
2222
rInt := acctest.RandInt()
2323

2424
defaults = gitlab.Project{
@@ -46,8 +46,8 @@ func TestAccGitlabProject_basic(t *testing.T) {
4646
PagesAccessLevel: gitlab.PublicAccessControl,
4747
}
4848

49-
defaultsMasterBranch = defaults
50-
defaultsMasterBranch.DefaultBranch = "master"
49+
defaultsMainBranch = defaults
50+
defaultsMainBranch.DefaultBranch = "main"
5151

5252
resource.Test(t, resource.TestCase{
5353
PreCheck: func() { testAccPreCheck(t) },
@@ -100,11 +100,11 @@ func TestAccGitlabProject_basic(t *testing.T) {
100100
// Update the project creating the default branch
101101
{
102102
// Get the ID from the project data at the previous step
103-
SkipFunc: testAccGitlabProjectConfigDefaultBranchSkipFunc(&received, "master"),
104-
Config: testAccGitlabProjectConfigDefaultBranch(rInt, "master"),
103+
SkipFunc: testAccGitlabProjectConfigDefaultBranchSkipFunc(&received, "main"),
104+
Config: testAccGitlabProjectConfigDefaultBranch(rInt, "main"),
105105
Check: resource.ComposeTestCheckFunc(
106106
testAccCheckGitlabProjectExists("gitlab_project.foo", &received),
107-
testAccCheckAggregateGitlabProject(&defaultsMasterBranch, &received),
107+
testAccCheckAggregateGitlabProject(&defaultsMainBranch, &received),
108108
),
109109
},
110110
// Test import without push rules (checks read function)
@@ -198,7 +198,7 @@ max_file_size = 1234
198198
// NOTE: The push rules will still exist upstream because the push_rules block is computed.
199199
{
200200
SkipFunc: isRunningInCE,
201-
Config: testAccGitlabProjectConfigDefaultBranch(rInt, "master"),
201+
Config: testAccGitlabProjectConfigDefaultBranch(rInt, "main"),
202202
Check: testAccCheckGitlabProjectPushRules("gitlab_project.foo", &gitlab.ProjectPushRules{
203203
AuthorEmailRegex: "foo_author",
204204
}),
@@ -213,7 +213,7 @@ max_file_size = 1234
213213
},
214214
// Destroy the project so we can next test creating a project with push rules simultaneously
215215
{
216-
Config: testAccGitlabProjectConfigDefaultBranch(rInt, "master"),
216+
Config: testAccGitlabProjectConfigDefaultBranch(rInt, "main"),
217217
Destroy: true,
218218
Check: testAccCheckGitlabProjectDestroy,
219219
},
@@ -325,7 +325,7 @@ func TestAccGitlabProject_initializeWithReadme(t *testing.T) {
325325
Check: resource.ComposeTestCheckFunc(
326326
testAccCheckGitlabProjectExists("gitlab_project.foo", &project),
327327
testAccCheckGitlabProjectDefaultBranch(&project, &testAccGitlabProjectExpectedAttributes{
328-
DefaultBranch: "master",
328+
DefaultBranch: "main",
329329
}),
330330
),
331331
},
@@ -506,7 +506,7 @@ func TestAccGitlabProject_importURL(t *testing.T) {
506506

507507
// Add a file to the base project, for later verifying the import.
508508
_, _, err = client.RepositoryFiles.CreateFile(baseProject.ID, "foo.txt", &gitlab.CreateFileOptions{
509-
Branch: gitlab.String("master"),
509+
Branch: gitlab.String("main"),
510510
CommitMessage: gitlab.String("add file"),
511511
Content: gitlab.String(""),
512512
})
@@ -526,7 +526,7 @@ func TestAccGitlabProject_importURL(t *testing.T) {
526526
func(state *terraform.State) error {
527527
projectID := state.RootModule().Resources["gitlab_project.imported"].Primary.ID
528528

529-
_, _, err := client.RepositoryFiles.GetFile(projectID, "foo.txt", &gitlab.GetFileOptions{Ref: gitlab.String("master")}, nil)
529+
_, _, err := client.RepositoryFiles.GetFile(projectID, "foo.txt", &gitlab.GetFileOptions{Ref: gitlab.String("main")}, nil)
530530
if err != nil {
531531
return fmt.Errorf("failed to get file from imported project: %w", err)
532532
}
@@ -590,7 +590,7 @@ func TestAccGitlabProject_importURLMirrored(t *testing.T) {
590590

591591
// Add a file to the base project, for later verifying the import.
592592
_, _, err = client.RepositoryFiles.CreateFile(baseProject.ID, "foo.txt", &gitlab.CreateFileOptions{
593-
Branch: gitlab.String("master"),
593+
Branch: gitlab.String("main"),
594594
CommitMessage: gitlab.String("add file"),
595595
Content: gitlab.String(""),
596596
})
@@ -620,7 +620,7 @@ func TestAccGitlabProject_importURLMirrored(t *testing.T) {
620620
func(state *terraform.State) error {
621621
projectID := state.RootModule().Resources["gitlab_project.imported"].Primary.ID
622622

623-
_, _, err := client.RepositoryFiles.GetFile(projectID, "foo.txt", &gitlab.GetFileOptions{Ref: gitlab.String("master")}, nil)
623+
_, _, err := client.RepositoryFiles.GetFile(projectID, "foo.txt", &gitlab.GetFileOptions{Ref: gitlab.String("main")}, nil)
624624
if err != nil {
625625
return fmt.Errorf("failed to get file from imported project: %w", err)
626626
}
@@ -647,7 +647,7 @@ func TestAccGitlabProject_importURLMirrored(t *testing.T) {
647647
func(state *terraform.State) error {
648648
projectID := state.RootModule().Resources["gitlab_project.imported"].Primary.ID
649649

650-
_, _, err := client.RepositoryFiles.GetFile(projectID, "foo.txt", &gitlab.GetFileOptions{Ref: gitlab.String("master")}, nil)
650+
_, _, err := client.RepositoryFiles.GetFile(projectID, "foo.txt", &gitlab.GetFileOptions{Ref: gitlab.String("main")}, nil)
651651
if err != nil {
652652
return fmt.Errorf("failed to get file from imported project: %w", err)
653653
}
@@ -674,7 +674,7 @@ func TestAccGitlabProject_importURLMirrored(t *testing.T) {
674674
func(state *terraform.State) error {
675675
projectID := state.RootModule().Resources["gitlab_project.imported"].Primary.ID
676676

677-
_, _, err := client.RepositoryFiles.GetFile(projectID, "foo.txt", &gitlab.GetFileOptions{Ref: gitlab.String("master")}, nil)
677+
_, _, err := client.RepositoryFiles.GetFile(projectID, "foo.txt", &gitlab.GetFileOptions{Ref: gitlab.String("main")}, nil)
678678
if err != nil {
679679
return fmt.Errorf("failed to get file from imported project: %w", err)
680680
}
@@ -1015,7 +1015,7 @@ func testAccGitlabProjectConfigImportURL(rInt int, importURL string) string {
10151015
return fmt.Sprintf(`
10161016
resource "gitlab_project" "imported" {
10171017
name = "imported-%d"
1018-
default_branch = "master"
1018+
default_branch = "main"
10191019
import_url = "%s"
10201020
10211021
# So that acceptance tests can be run in a gitlab organization
@@ -1029,7 +1029,7 @@ func testAccGitlabProjectConfigImportURLMirror(rInt int, importURL string) strin
10291029
return fmt.Sprintf(`
10301030
resource "gitlab_project" "imported" {
10311031
name = "imported-%d"
1032-
default_branch = "master"
1032+
default_branch = "main"
10331033
import_url = "%s"
10341034
mirror = true
10351035
mirror_trigger_builds = true
@@ -1047,7 +1047,7 @@ func testAccGitlabProjectConfigImportURLMirrorDisabledOptionals(rInt int, import
10471047
return fmt.Sprintf(`
10481048
resource "gitlab_project" "imported" {
10491049
name = "imported-%d"
1050-
default_branch = "master"
1050+
default_branch = "main"
10511051
import_url = "%s"
10521052
mirror = true
10531053
mirror_trigger_builds = false
@@ -1065,7 +1065,7 @@ func testAccGitlabProjectConfigImportURLMirrorDisabled(rInt int, importURL strin
10651065
return fmt.Sprintf(`
10661066
resource "gitlab_project" "imported" {
10671067
name = "imported-%d"
1068-
default_branch = "master"
1068+
default_branch = "main"
10691069
import_url = "%s"
10701070
mirror = false
10711071
mirror_trigger_builds = false
@@ -1085,7 +1085,7 @@ resource "gitlab_project" "foo" {
10851085
name = "foo-%[1]d"
10861086
path = "foo.%[1]d"
10871087
description = "Terraform acceptance tests"
1088-
default_branch = "master"
1088+
default_branch = "main"
10891089
10901090
push_rules {
10911091
%[2]s
@@ -1112,7 +1112,7 @@ resource "gitlab_project" "template-name" {
11121112
// 2020-09-07: Currently Gitlab (version 13.3.6 ) doesn't allow in admin API
11131113
// ability to set a group as instance level templates.
11141114
// To test resource_gitlab_project_test template features we add
1115-
// group, project myrails and admin settings directly in scripts/start-gitlab.sh
1115+
// group, project myrails and admin settings directly in scripts/healthcheck-and-setup.sh
11161116
// Once Gitlab add admin template in API we could manage group/project/settings
11171117
// directly in tests like TestAccGitlabProject_basic.
11181118
func testAccGitlabProjectConfigTemplateNameCustom(rInt int) string {

0 commit comments

Comments
 (0)