Skip to content

Commit f7509ab

Browse files
author
Michael Chmielewski
committed
Add test to verify #1157 is fixed.
Updating only a non-blessed project field (`analytics_access_level`), should not cause the provider to fail because we now also always pass in the project name with update project API calls.
1 parent 1bb146e commit f7509ab

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

internal/provider/resource_gitlab_project_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,56 @@ func TestAccGitlabProject_templateMutualExclusiveNameAndID(t *testing.T) {
11391139
})
11401140
}
11411141

1142+
// Gitlab update project API call requires one from a subset of project fields to be set (See #1157)
1143+
// If only a non-blessed field is changed, this test checks that the provider ensures the code won't return an error.
1144+
func TestAccGitlabProject_UpdateAnalyticsAccessLevel(t *testing.T) {
1145+
var received gitlab.Project
1146+
rInt := acctest.RandInt()
1147+
1148+
resource.Test(t, resource.TestCase{
1149+
ProviderFactories: providerFactories,
1150+
CheckDestroy: testAccCheckGitlabProjectDestroy,
1151+
Steps: []resource.TestStep{
1152+
// Create minimal test project
1153+
{
1154+
Config: fmt.Sprintf(`
1155+
resource "gitlab_project" "this" {
1156+
name = "foo-%d"
1157+
visibility_level = "public"
1158+
}`, rInt),
1159+
Check: resource.ComposeTestCheckFunc(
1160+
testAccCheckGitlabProjectExists("gitlab_project.this", &received),
1161+
),
1162+
},
1163+
// Verify Import
1164+
{
1165+
ResourceName: "gitlab_project.this",
1166+
ImportState: true,
1167+
ImportStateVerify: true,
1168+
},
1169+
// Update `analytics_access_level`
1170+
{
1171+
Config: fmt.Sprintf(`
1172+
resource "gitlab_project" "this" {
1173+
name = "foo-%d"
1174+
visibility_level = "public"
1175+
analytics_access_level = "disabled"
1176+
}`, rInt),
1177+
Check: resource.ComposeTestCheckFunc(
1178+
testAccCheckGitlabProjectExists("gitlab_project.this", &received),
1179+
resource.TestCheckResourceAttr("gitlab_project.this", "analytics_access_level", "disabled"),
1180+
),
1181+
},
1182+
// Verify Import
1183+
{
1184+
ResourceName: "gitlab_project.this",
1185+
ImportState: true,
1186+
ImportStateVerify: true,
1187+
},
1188+
},
1189+
})
1190+
}
1191+
11421192
func TestAccGitlabProject_containerExpirationPolicy(t *testing.T) {
11431193
var received gitlab.Project
11441194
rInt := acctest.RandInt()

0 commit comments

Comments
 (0)