6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-12 17:00:15 +00:00

Add branch status and tests

This commit is contained in:
Grzegorz Dlugoszewski
2020-05-27 20:30:04 +02:00
parent fd49a9e41d
commit 0b371341e7
8 changed files with 338 additions and 31 deletions

44
new/status_test.go Normal file
View File

@@ -0,0 +1,44 @@
package new
import "testing"
func TestBranchStatusLocal(t *testing.T) {
tr := NewRepoWithCommit(t)
tr.NewBranch("branch")
repo, err := OpenRepo(tr.Path)
checkFatal(t, err)
err = repo.LoadStatus()
checkFatal(t, err)
if repo.Status.Branches["master"].Upstream != nil {
t.Errorf("'master' branch should not have an upstream")
}
if repo.Status.Branches["branch"].Upstream != nil {
t.Errorf("'branch' branch should not have an upstream")
}
}
func TestBranchStatusCloned(t *testing.T) {
origin := NewRepoWithCommit(t)
clone := origin.Clone()
clone.NewBranch("local")
repo, err := OpenRepo(clone.Path)
checkFatal(t, err)
err = repo.LoadStatus()
checkFatal(t, err)
if repo.Status.Branches["master"].Upstream == nil {
t.Errorf("'master' branch should have an upstream")
}
if repo.Status.Branches["local"].Upstream != nil {
t.Errorf("'local' branch should not have an upstream")
}
}