1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-13 13:48:40 +02:00
goreleaser/internal/git/git_test.go
Carlos Alexandro Becker 850c2e14f2 fix: detect if current folder is a subfolder of a parent git repo
We were checking for a .git folder, which would break in cases
where goreleaser is running from a subfolder of a monorepo, for example.

Check 529af6f#commitcomment-25011738

Closes #402 #403
2017-10-16 15:59:39 -02:00

31 lines
609 B
Go

package git
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGit(t *testing.T) {
out, err := Run("status")
assert.NoError(t, err)
assert.NotEmpty(t, out)
out, err = Run("command-that-dont-exist")
assert.Error(t, err)
assert.Empty(t, out)
assert.Equal(
t,
"git: 'command-that-dont-exist' is not a git command. See 'git --help'.\n",
err.Error(),
)
}
func TestRepo(t *testing.T) {
assert.True(t, IsRepo(), "goreleaser folder should be a git repo")
assert.NoError(t, os.Chdir(os.TempDir()))
assert.False(t, IsRepo(), os.TempDir()+" folder should be a git repo")
}