1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/git/git_test.go

47 lines
1.0 KiB
Go
Raw Normal View History

package git_test
2017-08-19 17:47:04 +02:00
import (
"os"
2017-08-19 17:47:04 +02:00
"testing"
"github.com/goreleaser/goreleaser/internal/git"
2017-08-19 17:47:04 +02:00
"github.com/stretchr/testify/assert"
)
func TestGit(t *testing.T) {
out, err := git.Run("status")
assert.NoError(t, err)
assert.NotEmpty(t, out)
2017-08-19 17:47:04 +02:00
out, err = git.Run("command-that-dont-exist")
assert.Error(t, err)
assert.Empty(t, out)
2017-08-19 17:47:04 +02:00
assert.Equal(
t,
2017-08-19 17:47:04 +02:00
"git: 'command-that-dont-exist' is not a git command. See 'git --help'.\n",
err.Error(),
)
}
func TestRepo(t *testing.T) {
assert.True(t, git.IsRepo(), "goreleaser folder should be a git repo")
assert.NoError(t, os.Chdir(os.TempDir()))
assert.False(t, git.IsRepo(), os.TempDir()+" folder should be a git repo")
}
func TestClean(t *testing.T) {
out, err := git.Clean("asdasd 'ssadas'\nadasd", nil)
assert.NoError(t, err)
assert.Equal(t, "asdasd ssadas", out)
out, err = git.Clean(git.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'.",
err.Error(),
)
}