-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de12f84
commit cb42be3
Showing
1 changed file
with
47 additions
and
0 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,47 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"os" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestCloneBadInput(t *testing.T) { | ||
|
||
expected := "Error: is not a valid hostname." | ||
|
||
output := new(bytes.Buffer) | ||
rootCmd.SetOut(output) | ||
rootCmd.SetErr(output) | ||
|
||
rootCmd.SetArgs([]string{"clone", "chicken"}) | ||
|
||
rootCmd.Execute() | ||
|
||
if !strings.HasPrefix(output.String(), expected) { | ||
t.Errorf("`arc clone` with bad input should start with `%s`, result: `%s`", expected, output) | ||
} | ||
} | ||
|
||
func TestClonePass(t *testing.T) { | ||
|
||
// This test will modify the local filesystem. Thus, only runs in an CI | ||
// environment by default. | ||
if os.Getenv("CI") != "true" { | ||
t.Skip("skipping. Set envar CI=true to run.") | ||
} | ||
|
||
output := new(bytes.Buffer) | ||
rootCmd.SetOut(output) | ||
rootCmd.SetErr(output) | ||
|
||
rootCmd.SetArgs([]string{"clone", "https://github.com/hubci/arc.git"}) | ||
|
||
rootCmd.Execute() | ||
|
||
// check to see if repo was cloned | ||
if _, err := os.Stat("/home/circleci/Repos/hubci/arc/.git"); os.IsNotExist(err) { | ||
t.Error("`arc clone` failed to clone the arc repository.") | ||
} | ||
} |