github.com/crosseyed/versionbump@v1.1.0/internal/git_test.go (about)

     1  package internal
     2  
     3  import (
     4  	"github.com/stretchr/testify/assert"
     5  	"os"
     6  	"os/exec"
     7  	"path/filepath"
     8  	"testing"
     9  )
    10  
    11  func root() string {
    12  	abs, _ := filepath.Abs("..")
    13  	return abs
    14  }
    15  
    16  func TestGit_ListTags(t *testing.T) {
    17  	cwd, _ := os.Getwd()
    18  	defer os.Chdir(cwd) // nolint
    19  
    20  	tmpdir := filepath.Join(root(), "tmp")
    21  	gitsh := filepath.Join(root(), "test/fixtures/gittag.sh")
    22  	d := "gittestdir"
    23  	g := filepath.Join(tmpdir, d)
    24  
    25  	cmd := exec.Command(gitsh, d, tmpdir)
    26  	if err := cmd.Run(); err != nil {
    27  		assert.Fail(t, "", err)
    28  	}
    29  	bump := PlainOpen(g)
    30  
    31  	tags := bump.ListTags()
    32  	assert.True(t, len(tags) > 0)
    33  	assert.Contains(t, tags, "1.0.0")
    34  	assert.Contains(t, tags, "1.1.0")
    35  }
    36  
    37  func TestGit_ListTags_no_git(t *testing.T) {
    38  }
    39  
    40  func TestGit_ListTags_no_repo(t *testing.T) {
    41  }