git2go/clone_test.go

33 lines
599 B
Go
Raw Normal View History

2014-03-18 20:24:31 -05:00
package git
import (
"io/ioutil"
"testing"
)
2014-03-18 21:38:02 -05:00
func TestClone(t *testing.T) {
2014-03-18 20:24:31 -05:00
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)
2014-03-19 02:03:21 -05:00
2014-03-18 20:24:31 -05:00
seedTestRepo(t, repo)
path, err := ioutil.TempDir("", "git2go")
checkFatal(t, err)
ref, err := repo.References.Lookup("refs/heads/master")
checkFatal(t, err)
repo2, err := Clone(repo.Path(), path, &CloneOptions{Bare: true})
defer cleanupTestRepo(t, repo2)
2014-03-18 20:24:31 -05:00
checkFatal(t, err)
ref2, err := repo2.References.Lookup("refs/heads/master")
checkFatal(t, err)
if ref.Cmp(ref2) != 0 {
t.Fatal("reference in clone does not match original ref")
}
2014-03-18 20:24:31 -05:00
}