aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-02-13 23:59:49 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-02-13 23:59:49 +0100
commit65351f835dcaa4b50dd44bce7bf3f2e31582dadc (patch)
treec7c5750ace6769c3e983ef5414d1d7dd7e11f3b0 /repository_test.go
parentf8b5557875513c5b0aff24bb7b8e28f8f680976f (diff)
downloadgo-git-65351f835dcaa4b50dd44bce7bf3f2e31582dadc.tar.gz
Repository.Init now handles non-standard .git location
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go51
1 files changed, 49 insertions, 2 deletions
diff --git a/repository_test.go b/repository_test.go
index 84a7221..2c1d4a2 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -18,6 +18,7 @@ import (
. "gopkg.in/check.v1"
"srcd.works/go-billy.v1/memfs"
+ "srcd.works/go-billy.v1/osfs"
)
type RepositorySuite struct {
@@ -36,6 +37,52 @@ func (s *RepositorySuite) TestInit(c *C) {
c.Assert(cfg.Core.IsBare, Equals, false)
}
+func (s *RepositorySuite) TestInitNonStandardDotGit(c *C) {
+ dir, err := ioutil.TempDir("", "init-non-standard")
+ c.Assert(err, IsNil)
+ c.Assert(os.RemoveAll(dir), IsNil)
+
+ fs := osfs.New(dir)
+ storage, err := filesystem.NewStorage(fs.Dir("storage"))
+ c.Assert(err, IsNil)
+
+ r, err := Init(storage, fs.Dir("worktree"))
+ c.Assert(err, IsNil)
+ c.Assert(r, NotNil)
+
+ f, err := fs.Open("worktree/.git")
+ c.Assert(err, IsNil)
+
+ all, err := ioutil.ReadAll(f)
+ c.Assert(err, IsNil)
+ c.Assert(string(all), Equals, "gitdir: ../storage\n")
+
+ cfg, err := r.Config()
+ c.Assert(err, IsNil)
+ c.Assert(cfg.Core.Worktree, Equals, "../worktree")
+}
+
+func (s *RepositorySuite) TestInitStandardDotGit(c *C) {
+ dir, err := ioutil.TempDir("", "init-standard")
+ c.Assert(err, IsNil)
+ c.Assert(os.RemoveAll(dir), IsNil)
+
+ fs := osfs.New(dir)
+ storage, err := filesystem.NewStorage(fs.Dir(".git"))
+ c.Assert(err, IsNil)
+
+ r, err := Init(storage, fs)
+ c.Assert(err, IsNil)
+ c.Assert(r, NotNil)
+
+ l, err := fs.ReadDir(".git")
+ c.Assert(len(l) > 0, Equals, true)
+
+ cfg, err := r.Config()
+ c.Assert(err, IsNil)
+ c.Assert(cfg.Core.Worktree, Equals, "")
+}
+
func (s *RepositorySuite) TestInitBare(c *C) {
r, err := Init(memory.NewStorage(), nil)
c.Assert(err, IsNil)
@@ -306,7 +353,7 @@ func (s *RepositorySuite) TestCloneDeep(c *C) {
fi, err := fs.ReadDir("")
c.Assert(err, IsNil)
- c.Assert(fi, HasLen, 9)
+ c.Assert(fi, HasLen, 8)
}
func (s *RepositorySuite) TestCloneConfig(c *C) {
@@ -431,7 +478,7 @@ func (s *RepositorySuite) TestPullCheckout(c *C) {
fi, err := fs.ReadDir("")
c.Assert(err, IsNil)
- c.Assert(fi, HasLen, 9)
+ c.Assert(fi, HasLen, 8)
}
func (s *RepositorySuite) TestCloneWithProgress(c *C) {