Skip to content

Commit

Permalink
Cloning tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pearkes committed Jun 6, 2013
1 parent 56d867c commit 1a97997
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion steps/step_clone_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (*StepCloneRepo) Run(state map[string]interface{}) multistep.StepAction {

// If an error occurs, log and halt
if mkdirerr != nil {
log.Println(mkdirerr)
log.Println("Error creating directory for " + repo.FullName)
fmt.Printf("%s.%s", RED, CLEAR)
return multistep.ActionHalt
}
Expand Down
19 changes: 19 additions & 0 deletions steps/step_clone_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@ package steps

import (
"github.com/mitchellh/multistep"
"os"
"os/exec"
"testing"
)

func TestStepCloneRepo(t *testing.T) {
env := make(map[string]interface{})
env["path"] = "tmp"
os.MkdirAll("tmp/pearkes/origin", 0777)

// Create a fake repository to clone from
cmdInit := exec.Command("git", "init", "tmp/pearkes/origin")
// Commit to the repoistory to avoid warnings
os.Create("tmp/pearkes/origin/test")
cmdCommit := exec.Command("git", "commit", "-a", "-m", "'initial commit'")

cmdInit.Run()
cmdCommit.Run()

repo := Repo{FullName: "pearkes/test", SSHUrl: "tmp/pearkes/origin"}
env["repo"] = repo
env["repo_state"] = "clone"

step := &StepCloneRepo{}

Expand All @@ -15,4 +32,6 @@ func TestStepCloneRepo(t *testing.T) {
if results != multistep.ActionContinue {
t.Fatal("step did not return ActionContinue")
}

os.RemoveAll("tmp")
}

0 comments on commit 1a97997

Please sign in to comment.