github.com/axxelG/goreleaser@v0.92.0/internal/git/git_test.go (about)

     1  package git
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestGit(t *testing.T) {
    11  	out, err := Run("status")
    12  	assert.NoError(t, err)
    13  	assert.NotEmpty(t, out)
    14  
    15  	out, err = Run("command-that-dont-exist")
    16  	assert.Error(t, err)
    17  	assert.Empty(t, out)
    18  	assert.Equal(
    19  		t,
    20  		"git: 'command-that-dont-exist' is not a git command. See 'git --help'.\n",
    21  		err.Error(),
    22  	)
    23  }
    24  
    25  func TestRepo(t *testing.T) {
    26  	assert.True(t, IsRepo(), "goreleaser folder should be a git repo")
    27  
    28  	assert.NoError(t, os.Chdir(os.TempDir()))
    29  	assert.False(t, IsRepo(), os.TempDir()+" folder should be a git repo")
    30  }
    31  
    32  func TestClean(t *testing.T) {
    33  	out, err := Clean("asdasd 'ssadas'\nadasd", nil)
    34  	assert.NoError(t, err)
    35  	assert.Equal(t, "asdasd ssadas", out)
    36  
    37  	out, err = Clean(Run("command-that-dont-exist"))
    38  	assert.Error(t, err)
    39  	assert.Empty(t, out)
    40  	assert.Equal(
    41  		t,
    42  		"git: 'command-that-dont-exist' is not a git command. See 'git --help'.",
    43  		err.Error(),
    44  	)
    45  }