Skip to content

Commit

Permalink
fork test: Delete fork project on error
Browse files Browse the repository at this point in the history
The fork tests are failing with

        fork_test.go:122: Forking zaquestion/fork_test project...
            2021/04/06 00:19:49 fork.go:90: POST https://gitlab.com/api/v4/projects/5794886/fork: 409 {message: {name: [has already been taken]}, {path: [has already been taken]}}

because the fork_test_name_1 project was not properly deleted in a
previous test run.  The result is that a user must now take a manual step
of deleting the fork and/or modifying code to delete the fork.  Instead
this can be done by modifying the failure path to delete the fork.

Delete the fork project on error.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
  • Loading branch information
prarit committed Apr 6, 2021
1 parent f4aed0c commit 391bf23
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions cmd/fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ func Test_fork(t *testing.T) {
t.Fatal(err)
}

namespace := "lab-testing"
if test.namespace != "" {
namespace = test.namespace
}
name := test.name
if test.path != "" {
name = test.path
}
project := namespace + "/" + name

args := []string{"fork"}
if len(test.args) > 0 {
args = append(args, test.args...)
Expand All @@ -118,19 +128,10 @@ func Test_fork(t *testing.T) {
out := string(b)
if err != nil {
t.Log(out)
cleanupFork(t, project)
t.Fatal(err)
}

namespace := "lab-testing"
if test.namespace != "" {
namespace = test.namespace
}
name := test.name
if test.path != "" {
name = test.path
}
project := namespace + "/" + name

require.Contains(t, out, "From gitlab.com:"+project)
require.Contains(t, out, "new remote: "+namespace)

Expand Down

0 comments on commit 391bf23

Please sign in to comment.