aboutsummaryrefslogtreecommitdiffstats
path: root/fixtures
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-12 02:22:08 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-12 02:22:08 +0200
commitd57f90b78eeb6b09b15e3fe57609ede66df4edac (patch)
tree961aa929391c0e804f32d26016f9e385f6e70ecb /fixtures
parent58fe211f1b0e4863b425542d2fad15803276fd66 (diff)
downloadgo-git-d57f90b78eeb6b09b15e3fe57609ede66df4edac.tar.gz
fixtures: new fixture package being use in all packages
Diffstat (limited to 'fixtures')
-rw-r--r--fixtures/fixtures.go65
1 files changed, 56 insertions, 9 deletions
diff --git a/fixtures/fixtures.go b/fixtures/fixtures.go
index 8e1c0ed..db0db96 100644
--- a/fixtures/fixtures.go
+++ b/fixtures/fixtures.go
@@ -2,13 +2,13 @@ package fixtures
import (
"fmt"
- "io"
+ "go/build"
"os"
"path/filepath"
"github.com/alcortesm/tgz"
- check "gopkg.in/check.v1"
+ "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v4/core"
"gopkg.in/src-d/go-git.v4/utils/fs"
)
@@ -21,28 +21,47 @@ var folders []string
var fixtures = Fixtures{{
Tags: []string{"packfile", "ofs-delta", ".git"},
- URL: "https://github.com/git-fixtures/basic",
+ URL: "https://github.com/git-fixtures/basic.git",
Head: core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
PackfileHash: core.NewHash("a3fed42da1e8189a077c0e6846c040dcf73fc9dd"),
DotGitHash: core.NewHash("0a00a25543e6d732dbf4e8e9fec55c8e65fc4e8d"),
ObjectsCount: 31,
}, {
Tags: []string{"packfile", "ref-delta", ".git"},
- URL: "https://github.com/git-fixtures/basic",
+ URL: "https://github.com/git-fixtures/basic.git",
Head: core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
PackfileHash: core.NewHash("c544593473465e6315ad4182d04d366c4592b829"),
DotGitHash: core.NewHash("7cbde0ca02f13aedd5ec8b358ca17b1c0bf5ee64"),
ObjectsCount: 31,
}, {
- Tags: []string{".git", "unpacked", "multi-packfile"},
+ Tags: []string{"packfile", "ofs-delta", ".git", "single-branch"},
+ URL: "https://github.com/git-fixtures/basic.git",
+ Head: core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
+ PackfileHash: core.NewHash("61f0ee9c75af1f9678e6f76ff39fbe372b6f1c45"),
+ DotGitHash: core.NewHash("21504f6d2cc2ef0c9d6ebb8802c7b49abae40c1a"),
+ ObjectsCount: 28,
+}, {
+ Tags: []string{"packfile", ".git", "unpacked", "multi-packfile"},
URL: "https://github.com/src-d/go-git.git",
+ Head: core.NewHash("e8788ad9165781196e917292d6055cba1d78664e"),
+ PackfileHash: core.NewHash("3559b3b47e695b33b0913237a4df3357e739831c"),
DotGitHash: core.NewHash("174be6bd4292c18160542ae6dc6704b877b8a01a"),
ObjectsCount: 2133,
}, {
Tags: []string{"packfile"},
- URL: "https://github.com/spinnaker/spinnaker",
+ URL: "https://github.com/spinnaker/spinnaker.git",
Head: core.NewHash("06ce06d0fc49646c4de733c45b7788aabad98a6f"),
PackfileHash: core.NewHash("f2e0a8889a746f7600e07d2246a2e29a72f696be"),
+}, {
+ Tags: []string{"packfile"},
+ URL: "https://github.com/jamesob/desk.git",
+ Head: core.NewHash("d2313db6e7ca7bac79b819d767b2a1449abb0a5d"),
+ PackfileHash: core.NewHash("4ec6344877f494690fc800aceaf2ca0e86786acb"),
+}, {
+ Tags: []string{"packfile", "empty-folder"},
+ URL: "https://github.com/cpcs499/Final_Pres_P.git",
+ Head: core.NewHash("70bade703ce556c2c7391a8065c45c943e8b6bc3"),
+ PackfileHash: core.NewHash("29f304662fd64f102d94722cf5bd8802d9a9472c"),
}}
func All() Fixtures {
@@ -50,7 +69,8 @@ func All() Fixtures {
}
func Basic() Fixtures {
- return ByURL("https://github.com/git-fixtures/basic")
+ return ByURL("https://github.com/git-fixtures/basic.git").
+ Exclude("single-branch")
}
func ByURL(url string) Fixtures {
@@ -80,7 +100,7 @@ func (f *Fixture) Is(tag string) bool {
return false
}
-func (f *Fixture) Packfile() io.ReadSeeker {
+func (f *Fixture) Packfile() *os.File {
fn := filepath.Join(RootFolder, DataFolder, fmt.Sprintf("pack-%s.pack", f.PackfileHash))
file, err := os.Open(fn)
if err != nil {
@@ -90,7 +110,7 @@ func (f *Fixture) Packfile() io.ReadSeeker {
return file
}
-func (f *Fixture) Idx() io.ReadSeeker {
+func (f *Fixture) Idx() *os.File {
fn := filepath.Join(RootFolder, DataFolder, fmt.Sprintf("pack-%s.idx", f.PackfileHash))
file, err := os.Open(fn)
if err != nil {
@@ -144,3 +164,30 @@ func (g Fixtures) ByURL(url string) Fixtures {
return r
}
+
+func (g Fixtures) Exclude(tag string) Fixtures {
+ r := make(Fixtures, 0)
+ for _, f := range g {
+ if !f.Is(tag) {
+ r = append(r, f)
+ }
+ }
+
+ return r
+}
+
+type Suite struct{}
+
+func (s *Suite) SetUpSuite(c *check.C) {
+ RootFolder = filepath.Join(
+ build.Default.GOPATH,
+ "src", "gopkg.in/src-d/go-git.v4", "fixtures",
+ )
+}
+
+func (s *Suite) TearDownSuite(c *check.C) {
+ for _, f := range folders {
+ err := os.RemoveAll(f)
+ c.Assert(err, check.IsNil)
+ }
+}