mirror of
https://github.com/grdl/git-get.git
synced 2026-02-07 11:48:28 +00:00
Add CloneRepo function and unit tests for cloned repos status
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -29,3 +30,49 @@ func TestNewLocalBranch(t *testing.T) {
|
||||
t.Errorf("Wrong branch status, got %+v; want %+v", status, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClonedBranches(t *testing.T) {
|
||||
origin := newTestRepo(t)
|
||||
createFile(t, origin, "file")
|
||||
stageFile(t, origin, "file")
|
||||
createCommit(t, origin, "Initial commit")
|
||||
|
||||
repo, err := CloneRepo(origin.Path(), newTempDir(t))
|
||||
checkFatal(t, err)
|
||||
|
||||
createBranch(t, repo, "branch")
|
||||
|
||||
branches, err := Branches(repo)
|
||||
checkFatal(t, err)
|
||||
|
||||
master := branches["master"]
|
||||
wantMaster := BranchStatus{
|
||||
Name: "master",
|
||||
IsRemote: false,
|
||||
HasUpstream: true,
|
||||
}
|
||||
|
||||
originMaster := branches["origin/master"]
|
||||
wantOriginMaster := BranchStatus{
|
||||
Name: "origin/master",
|
||||
IsRemote: true,
|
||||
HasUpstream: false,
|
||||
}
|
||||
|
||||
branch := branches["branch"]
|
||||
wantBranch := BranchStatus{
|
||||
Name: "branch",
|
||||
IsRemote: false,
|
||||
HasUpstream: false,
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(master, wantMaster) {
|
||||
t.Errorf("Wrong branch status, got %+v; want %+v", master, wantMaster)
|
||||
}
|
||||
if !reflect.DeepEqual(originMaster, wantOriginMaster) {
|
||||
t.Errorf("Wrong branch status, got %+v; want %+v", originMaster, wantOriginMaster)
|
||||
}
|
||||
if !reflect.DeepEqual(branch, wantBranch) {
|
||||
t.Errorf("Wrong branch status, got %+v; want %+v", branch, wantBranch)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user