Skip to content

Commit

Permalink
fork: add test for --no-wait option
Browse files Browse the repository at this point in the history
Even though we don't have a big enough repo for testing the feature
properly, it's important keep a test for it, just in case.

Signed-off-by: Bruno Meneguele <[email protected]>
  • Loading branch information
bmeneg committed Dec 18, 2020
1 parent d980c61 commit df3d8a9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cmd/fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,36 @@ func Test_fork(t *testing.T) {
}
}

func Test_forkWait(t *testing.T) {
repo := copyTestRepo(t)
os.Remove(path.Join(repo, ".git/config"))

cmd := exec.Command("git", "remote", "add", "origin", "[email protected]:zaquestion/fork_test")
cmd.Dir = repo
err := cmd.Run()
if err != nil {
t.Fatal(err)
}

// The default behavior is to "wait" for the fork and it's already being
// tested in the Test_fork() test. Here we only test the --no-wait
// option, which we can't effectively test because we don't have a big
// enough repo.
t.Run("fork_nowait", func(t *testing.T) {
cmd = exec.Command(labBinaryPath, []string{"fork", "--no-wait"}...)
cmd.Dir = repo
b, err := cmd.CombinedOutput()
out := string(b)
if err != nil {
t.Log(out)
t.Fatal(err)
}
require.Contains(t, out, "From gitlab.com:lab-testing/fork_test")
require.Contains(t, out, "new remote: lab-testing")
cleanupFork(t, "fork_test")
})
}

func Test_determineForkRemote(t *testing.T) {
tests := []struct {
desc string
Expand Down

0 comments on commit df3d8a9

Please sign in to comment.