Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 4417138

Browse files
authored
fixtures: initialize fixtures into separated methods (#214)
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.
1 parent 4fe64a1 commit 4417138

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

fixtures/fixtures.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,34 @@ func (g Fixtures) Exclude(tag string) Fixtures {
264264
return r
265265
}
266266

267-
type Suite struct{}
268-
269-
func (s *Suite) SetUpSuite(c *check.C) {
267+
// Init set the correct path to be able to access to the fixtures files
268+
func Init() {
270269
RootFolder = filepath.Join(
271270
build.Default.GOPATH,
272271
"src", "gopkg.in/src-d/go-git.v4", "fixtures",
273272
)
274273
}
275274

276-
func (s *Suite) TearDownSuite(c *check.C) {
275+
// Clean cleans all the temporal files created
276+
func Clean() error {
277277
for f := range folders {
278278
err := os.RemoveAll(f)
279-
c.Assert(err, check.IsNil)
279+
if err != nil {
280+
return err
281+
}
280282

281283
delete(folders, f)
282284
}
285+
286+
return nil
287+
}
288+
289+
type Suite struct{}
290+
291+
func (s *Suite) SetUpSuite(c *check.C) {
292+
Init()
293+
}
294+
295+
func (s *Suite) TearDownSuite(c *check.C) {
296+
c.Assert(Clean(), check.IsNil)
283297
}

0 commit comments

Comments
 (0)