1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/internal/git/git_test.go
Carlos Alexandro Becker 2ea883e0c4
* feat: allow snapshots on a folder that is not a git repo (#579)
* feat: allow running against a folder that is not a git repo

* test: cover clean err

* test: release: increase coverage

* test: fix race condition
2018-02-25 20:17:45 -03:00

46 lines
965 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")
}
func TestClean(t *testing.T) {
out, err := Clean("asdasd 'ssadas'\nadasd", nil)
assert.NoError(t, err)
assert.Equal(t, "asdasd ssadas", out)
out, err = Clean(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(),
)
}