6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-10 09:39:20 +00:00

Add a basic branch status parser

This commit is contained in:
Grzegorz Dlugoszewski
2020-05-18 22:53:06 +02:00
parent 242d17ceb5
commit 9757a96d34
4 changed files with 85 additions and 25 deletions

View File

@@ -1,18 +1,27 @@
package main
import (
"fmt"
"testing"
git "github.com/libgit2/git2go/v30"
"github.com/pkg/errors"
)
func TestBranches(t *testing.T) {
repo, err := git.OpenRepository("/home/grdl/workspace/gitlab.com/grdl/git-get")
checkFatal(t, err)
func TestNewBranch(t *testing.T) {
repo := newTestRepo(t)
branches, err := Branches(repo)
checkFatal(t, err)
createFile(t, repo, "file")
stageFile(t, repo, "file")
createCommit(t, repo, "Initial commit")
branch := createBranch(t, repo, "branch")
fmt.Println(len(branches))
status, err := NewBranchStatus(branch)
checkFatal(t, errors.Wrap(err, "Failed getting branch status"))
if status.Name != "branch" {
t.Errorf("Wrong branch name, got %s; want %s", status.Name, "branch")
}
if status.IsRemote != false {
t.Errorf("Branch should be local")
}
}