mirror of
https://github.com/grdl/git-get.git
synced 2026-02-05 17:43:48 +00:00
Refactor Repo code and tests
- Add Repo as a separate type - Merge together repo status and branches status - Load status on repo opening
This commit is contained in:
@@ -10,14 +10,16 @@ func TestFetch(t *testing.T) {
|
||||
createCommit(t, origin, "Initial commit")
|
||||
|
||||
// Clone the origin repo
|
||||
repo, err := CloneRepo(origin.Path(), newTempDir(t))
|
||||
dir := newTempDir(t)
|
||||
err := CloneRepo(origin.Path(), dir)
|
||||
checkFatal(t, err)
|
||||
|
||||
// Open cloned repo and load its status
|
||||
repo, err := OpenRepo(dir)
|
||||
checkFatal(t, err)
|
||||
|
||||
// Check cloned status. It should not be behind origin
|
||||
status, err := NewRepoStatus(repo.Workdir())
|
||||
checkFatal(t, err)
|
||||
|
||||
if status.BranchStatuses["master"].Behind != 0 {
|
||||
if repo.Status.Branches["master"].Behind != 0 {
|
||||
t.Errorf("Master should not be behind")
|
||||
}
|
||||
|
||||
@@ -27,16 +29,17 @@ func TestFetch(t *testing.T) {
|
||||
createCommit(t, origin, "Second commit")
|
||||
|
||||
// Fetch cloned repo and check the status again
|
||||
err = Fetch(repo)
|
||||
status, err = NewRepoStatus(repo.Workdir())
|
||||
err = repo.Fetch()
|
||||
checkFatal(t, err)
|
||||
err = repo.Reload()
|
||||
checkFatal(t, err)
|
||||
|
||||
// Cloned master should now be 1 commit behind origin
|
||||
if status.BranchStatuses["master"].Behind != 1 {
|
||||
if repo.Status.Branches["master"].Behind != 1 {
|
||||
t.Errorf("Master should be 1 commit behind")
|
||||
}
|
||||
|
||||
if status.BranchStatuses["master"].Ahead != 0 {
|
||||
if repo.Status.Branches["master"].Ahead != 0 {
|
||||
t.Errorf("Master should not be ahead")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user