Skip to content

Commit c633526

Browse files
committed
refactor for go-gitlab
1 parent a9c161a commit c633526

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

test/integration/cloudbuild_repo_connection_gitlab/cloudbuild_repo_connection_gitlab_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (gl *GitLabClient) AddFileToProject(file []byte) {
9393
}
9494

9595
func (gl *GitLabClient) DeleteProject() {
96-
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName())
96+
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName(), utils.GetDeleteProjectOptions())
9797
if resp.StatusCode != 404 && err != nil {
9898
gl.t.Errorf("error deleting project with status %s and error %s", resp.Status, err.Error())
9999
}

test/integration/im_cloudbuild_workspace_gitlab/im_cloudbuild_workspace_gitlab_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (gl *GitLabClient) AddFileToProject(file []byte) {
9595
}
9696

9797
func (gl *GitLabClient) DeleteProject() {
98-
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName())
98+
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName(), utils.GetDeleteProjectOptions())
9999
if err != nil {
100100
gl.t.Errorf("error deleting project with status %s and error %s", resp.Status, err.Error())
101101
}

test/integration/tf_cloudbuild_builder_simple_gitlab/tf_cloudbuild_builder_simple_gitlab_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (gl *GitLabClient) CreateProject() {
8383
}
8484

8585
func (gl *GitLabClient) DeleteProject() {
86-
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName())
86+
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName(), utils.GetDeleteProjectOptions())
8787
if resp.StatusCode != 404 && err != nil {
8888
gl.t.Errorf("error deleting project with status %s and error %s", resp.Status, err.Error())
8989
}

test/integration/tf_cloudbuild_workspace_simple_gitlab/tf_cloudbuild_workspace_simple_gitlab_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (gl *GitLabClient) AddFileToProject(file []byte) {
9595
}
9696

9797
func (gl *GitLabClient) DeleteProject() {
98-
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName())
98+
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName(), utils.GetDeleteProjectOptions())
9999
if resp.StatusCode != 404 && err != nil {
100100
gl.t.Errorf("error deleting project with status %s and error %s", resp.Status, err.Error())
101101
}

test/integration/utils/utils.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"testing"
2121

2222
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
23+
"github.com/xanzy/go-gitlab"
2324
)
2425

2526
// GetRandomStringFromSetup gets a random string output variable setup.
@@ -44,3 +45,11 @@ func GetFileContents(t *testing.T, path string) []byte {
4445
func LastElement(str, sep string) string {
4546
return strings.Split(str, sep)[len(strings.Split(str, sep))-1]
4647
}
48+
49+
// GetDeleteProjectOptions returns default DeleteProjectOptions
50+
func GetDeleteProjectOptions() *gitlab.DeleteProjectOptions {
51+
return &gitlab.DeleteProjectOptions{
52+
FullPath: gitlab.Ptr("group/project"),
53+
PermanentlyRemove: gitlab.Ptr(true),
54+
}
55+
}

0 commit comments

Comments
 (0)