-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from zaquestion/tests-cmd-3
(tests) Tests for cmd/root, cmd/clone, and cmd/fork
- Loading branch information
Showing
4 changed files
with
167 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package cmd | ||
|
||
import ( | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_clone(t *testing.T) { | ||
repo := copyTestRepo(t) | ||
cmd := exec.Command("../lab_bin", "clone", "test") | ||
cmd.Dir = repo | ||
|
||
b, err := cmd.CombinedOutput() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
out := string(b) | ||
|
||
assert.Contains(t, out, "Cloning into 'test'...") | ||
assert.Contains(t, out, " * [new branch] master -> upstream/master") | ||
assert.Contains(t, out, "new remote: upstream") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package cmd | ||
|
||
import ( | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_fork(t *testing.T) { | ||
repo := copyTestRepo(t) | ||
// remove the remote so we can test adding it back | ||
// NOTE: we aren't actually going to test that forks are created on | ||
// GitLab, just that lab behaves correctly when a fork exists. | ||
cmd := exec.Command("git", "remote", "remove", "lab-testing") | ||
cmd.Dir = repo | ||
err := cmd.Run() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
cmd = exec.Command("../lab_bin", "fork") | ||
cmd.Dir = repo | ||
|
||
b, err := cmd.CombinedOutput() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
out := string(b) | ||
|
||
require.Contains(t, out, "From gitlab.com:lab-testing/test") | ||
require.Contains(t, out, "new remote: lab-testing") | ||
|
||
cmd = exec.Command("git", "remote", "-v") | ||
cmd.Dir = repo | ||
|
||
b, err = cmd.CombinedOutput() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
require.Contains(t, string(b), "lab-testing") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters