aboutsummaryrefslogtreecommitdiffstats
path: root/fixtures
diff options
context:
space:
mode:
authorAntonio Navarro Perez <antnavper@gmail.com>2017-01-19 14:14:07 +0100
committerGitHub <noreply@github.com>2017-01-19 14:14:07 +0100
commit441713897ef5604e8105379f45ebb982ab2c9a75 (patch)
treeaae74ff8a06fbbeba16cf5d1f377dd09a3b5095c /fixtures
parent4fe64a1484f61130c282c5d415501f549658e9ab (diff)
downloadgo-git-441713897ef5604e8105379f45ebb982ab2c9a75.tar.gz
fixtures: initialize fixtures into separated methods (#214)v4.0.0-rc7
To be able to use fixtures with other test frameworks than go-check, we created two methods, one to set fixtures path correctly, and another to remove all the temporal data created when testing.
Diffstat (limited to 'fixtures')
-rw-r--r--fixtures/fixtures.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/fixtures/fixtures.go b/fixtures/fixtures.go
index 9c6413c..8311d8b 100644
--- a/fixtures/fixtures.go
+++ b/fixtures/fixtures.go
@@ -264,20 +264,34 @@ func (g Fixtures) Exclude(tag string) Fixtures {
return r
}
-type Suite struct{}
-
-func (s *Suite) SetUpSuite(c *check.C) {
+// Init set the correct path to be able to access to the fixtures files
+func Init() {
RootFolder = filepath.Join(
build.Default.GOPATH,
"src", "gopkg.in/src-d/go-git.v4", "fixtures",
)
}
-func (s *Suite) TearDownSuite(c *check.C) {
+// Clean cleans all the temporal files created
+func Clean() error {
for f := range folders {
err := os.RemoveAll(f)
- c.Assert(err, check.IsNil)
+ if err != nil {
+ return err
+ }
delete(folders, f)
}
+
+ return nil
+}
+
+type Suite struct{}
+
+func (s *Suite) SetUpSuite(c *check.C) {
+ Init()
+}
+
+func (s *Suite) TearDownSuite(c *check.C) {
+ c.Assert(Clean(), check.IsNil)
}