Skip to content

Commit df6c7ee

Browse files
committed
delete_project_hook_test: get the id of created hook to delete instead of hardcoding it
1 parent 6f76bb9 commit df6c7ee

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

cmd/delete_project_hook_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package cmd
2222

2323
import (
2424
"fmt"
25+
"strconv"
2526
"testing"
2627

2728
"github.com/stretchr/testify/require"
@@ -37,7 +38,7 @@ func TestDeleteProjectHook(t *testing.T) {
3738
}{
3839
{
3940
name: "successfully delete a project hook",
40-
args: []string{"6"},
41+
args: []string{""}, // to be filled in test setup
4142
flagsMap: map[string]string{
4243
"project": "23",
4344
},
@@ -55,14 +56,17 @@ func TestDeleteProjectHook(t *testing.T) {
5556

5657
for _, tc := range tt {
5758
t.Run(tc.name, func(t *testing.T) {
59+
// SETUP
60+
// Create the project, get it's id for testing
5861
if tc.expect == pass {
5962
sampleHookURL := "http://example.com/"
60-
_, err := newProjectHook("23", &gitlab.AddProjectHookOptions{
63+
hook, err := newProjectHook("23", &gitlab.AddProjectHookOptions{
6164
URL: &sampleHookURL,
6265
})
6366
if err != nil {
6467
tInfo(fmt.Sprintf("failed to create project hook %s", tc.args[0]))
6568
}
69+
tc.args[0] = strconv.Itoa(hook.ID)
6670
}
6771

6872
execT := execTestCmdFlags{

0 commit comments

Comments
 (0)