Skip to content

Commit

Permalink
Merge pull request hashicorp#48 from hashicorp/b-git-test
Browse files Browse the repository at this point in the history
Git test should use "echo" and trim space locally
  • Loading branch information
mitchellh authored Feb 7, 2017
2 parents cc80f38 + 0983da0 commit 94eb49e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions get_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
)

Expand Down Expand Up @@ -295,14 +297,21 @@ func TestGitGetter_submodule(t *testing.T) {
}

func TestGitGetter_setupGitEnv_sshKey(t *testing.T) {
cmd := exec.Command("/bin/sh", "-c", "echo -n $GIT_SSH_COMMAND")
if runtime.GOOS == "windows" {
t.Skipf("skipping on windows since the test requires sh")
return
}

cmd := exec.Command("/bin/sh", "-c", "echo $GIT_SSH_COMMAND")
setupGitEnv(cmd, "/tmp/foo.pem")
out, err := cmd.Output()
if err != nil {
t.Fatal(err)
}
if string(out) != "ssh -i /tmp/foo.pem" {
t.Fatalf("unexpected GIT_SSH_COMMAND: %q", string(out))

actual := strings.TrimSpace(string(out))
if actual != "ssh -i /tmp/foo.pem" {
t.Fatalf("unexpected GIT_SSH_COMMAND: %q", actual)
}
}

Expand Down

0 comments on commit 94eb49e

Please sign in to comment.