2017-09-26 23:50:00 +02:00
|
|
|
package git
|
2017-08-19 17:47:04 +02:00
|
|
|
|
|
|
|
import (
|
2017-10-16 19:43:26 +02:00
|
|
|
"os"
|
2017-08-19 17:47:04 +02:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGit(t *testing.T) {
|
2017-09-26 23:50:00 +02:00
|
|
|
out, err := Run("status")
|
2017-09-27 00:24:49 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEmpty(t, out)
|
2017-08-19 17:47:04 +02:00
|
|
|
|
2017-09-26 23:50:00 +02:00
|
|
|
out, err = Run("command-that-dont-exist")
|
2017-09-27 00:24:49 +02:00
|
|
|
assert.Error(t, err)
|
|
|
|
assert.Empty(t, out)
|
2017-08-19 17:47:04 +02:00
|
|
|
assert.Equal(
|
2017-09-27 00:24:49 +02:00
|
|
|
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(),
|
|
|
|
)
|
|
|
|
}
|
2017-10-16 19:43:26 +02:00
|
|
|
|
|
|
|
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")
|
|
|
|
}
|
2017-10-16 00:47:52 +02:00
|
|
|
|
|
|
|
func TestClean(t *testing.T) {
|
|
|
|
out, err := Clean("asdasd 'ssadas'\nadasd", nil)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, "asdasd ssadas", out)
|
|
|
|
}
|