Skip to content

Commit

Permalink
fixtures: initialize fixtures into separated methods (#214)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ajnavarro committed Jan 19, 2017
1 parent 4fe64a1 commit 4417138
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions fixtures/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 4417138

Please sign in to comment.