Skip to content

Commit 8a487be

Browse files
committed
Add testing values, add cleanup function.
1 parent fc89636 commit 8a487be

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

internal/provider/data_source_gitlab_current_user_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,30 @@ import (
1313
func TestAccDataSourceGitlabCurrentUser_basic(t *testing.T) {
1414
//The root user has no public email by default, set the public email so it shows up properly.
1515
_, _, _ = testGitlabClient.Users.ModifyUser(1, &gitlab.ModifyUserOptions{
16-
Email: gitlab.String("[email protected]"),
1716
// The public email MUST match an email on record for the user, or it gets a bad request.
1817
PublicEmail: gitlab.String("[email protected]"),
1918
})
2019

20+
t.Cleanup(func() {
21+
_, _, _ = testGitlabClient.Users.ModifyUser(1, &gitlab.ModifyUserOptions{
22+
//Set back to the empty state on test completion.
23+
PublicEmail: gitlab.String(""),
24+
})
25+
})
26+
2127
resource.Test(t, resource.TestCase{
2228
ProviderFactories: providerFactories,
2329
Steps: []resource.TestStep{
2430
{
2531
Config: `data "gitlab_current_user" "this" {}`,
2632
Check: resource.ComposeTestCheckFunc(
27-
resource.TestCheckResourceAttrSet("data.gitlab_current_user.this", "id"),
28-
resource.TestCheckResourceAttrSet("data.gitlab_current_user.this", "name"),
29-
resource.TestCheckResourceAttrSet("data.gitlab_current_user.this", "username"),
30-
resource.TestCheckResourceAttrSet("data.gitlab_current_user.this", "bot"),
31-
resource.TestCheckResourceAttrSet("data.gitlab_current_user.this", "group_count"),
32-
resource.TestCheckResourceAttrSet("data.gitlab_current_user.this", "namespace_id"),
33-
resource.TestCheckResourceAttrSet("data.gitlab_current_user.this", "public_email"),
33+
resource.TestCheckResourceAttr("data.gitlab_current_user.this", "id", "gid://gitlab/User/1"),
34+
resource.TestCheckResourceAttr("data.gitlab_current_user.this", "name", "Administrator"),
35+
resource.TestCheckResourceAttr("data.gitlab_current_user.this", "username", "root"),
36+
resource.TestCheckResourceAttr("data.gitlab_current_user.this", "bot", "false"),
37+
resource.TestCheckResourceAttr("data.gitlab_current_user.this", "group_count", "2"),
38+
resource.TestCheckResourceAttr("data.gitlab_current_user.this", "namespace_id", "gid://gitlab/Namespaces::UserNamespace/1"),
39+
resource.TestCheckResourceAttr("data.gitlab_current_user.this", "public_email", "[email protected]"),
3440
),
3541
},
3642
},

internal/provider/graphql_helper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func TestAcc_GraphQL_basic(t *testing.T) {
1313

1414
query := GraphQLQuery{
15-
`query {currentUser {name, bot, gitpodEnabled, groupCount, id, namespace{id} publicEmail, username}}`,
15+
`query {currentUser {name, bot, gitpodEnabled, groupCount, id, namespace{id}, publicEmail, username}}`,
1616
}
1717

1818
var response CurrentUserResponse

0 commit comments

Comments
 (0)