github.com/devster/tarreleaser@v0.0.0-20221207180803-c608f4eb8918/pkg/git/git_test.go (about)

     1  package git
     2  
     3  import (
     4  	"github.com/stretchr/testify/assert"
     5  	"os"
     6  	"testing"
     7  )
     8  
     9  func TestHasGit(t *testing.T) {
    10  	assert.True(t, HasGit())
    11  }
    12  
    13  func TestRun(t *testing.T) {
    14  	assert := assert.New(t)
    15  
    16  	out, err := Run("status")
    17  	assert.NoError(err)
    18  	assert.NotEmpty(out)
    19  
    20  	out, err = Run("command-unknown")
    21  	assert.Error(err)
    22  	assert.Empty(out)
    23  }
    24  
    25  func TestIsRepo(t *testing.T) {
    26  	assert.True(t, IsRepo(), "current folder should be a git repo")
    27  
    28  	assert.NoError(t, os.Chdir(os.TempDir()))
    29  	assert.False(t, IsRepo(), os.TempDir()+" folder should not be a git repo")
    30  }