github.com/nkprince007/lab@v0.6.2-0.20171218071646-19d68b56f403/cmd/fork_test.go (about)

     1  package cmd
     2  
     3  import (
     4  	"os/exec"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func Test_fork(t *testing.T) {
    11  	repo := copyTestRepo(t)
    12  	// remove the remote so we can test adding it back
    13  	// NOTE: we aren't actually going to test that forks are created on
    14  	// GitLab, just that lab behaves correctly when a fork exists.
    15  	cmd := exec.Command("git", "remote", "remove", "lab-testing")
    16  	cmd.Dir = repo
    17  	err := cmd.Run()
    18  	if err != nil {
    19  		t.Fatal(err)
    20  	}
    21  
    22  	cmd = exec.Command("../lab_bin", "fork")
    23  	cmd.Dir = repo
    24  
    25  	b, err := cmd.CombinedOutput()
    26  	if err != nil {
    27  		t.Fatal(err)
    28  	}
    29  
    30  	out := string(b)
    31  
    32  	require.Contains(t, out, "From gitlab.com:lab-testing/test")
    33  	require.Contains(t, out, "new remote: lab-testing")
    34  
    35  	cmd = exec.Command("git", "remote", "-v")
    36  	cmd.Dir = repo
    37  
    38  	b, err = cmd.CombinedOutput()
    39  	if err != nil {
    40  		t.Fatal(err)
    41  	}
    42  	require.Contains(t, string(b), "lab-testing")
    43  }