diff options
Diffstat (limited to 'fixtures/fixtures.go')
-rw-r--r-- | fixtures/fixtures.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/fixtures/fixtures.go b/fixtures/fixtures.go index 503f2ea..7cfceae 100644 --- a/fixtures/fixtures.go +++ b/fixtures/fixtures.go @@ -3,6 +3,7 @@ package fixtures import ( "fmt" "go/build" + "io/ioutil" "os" "path/filepath" @@ -195,6 +196,25 @@ func (f *Fixture) DotGit() fs.Filesystem { return osfs.New(path) } +func (f *Fixture) Worktree() fs.Filesystem { + fn := filepath.Join(RootFolder, DataFolder, fmt.Sprintf("git-%s.tgz", f.DotGitHash)) + git, err := tgz.Extract(fn) + if err != nil { + panic(err) + } + + worktree, err := ioutil.TempDir("", "worktree") + if err != nil { + panic(err) + } + + if err := os.Rename(git, filepath.Join(worktree, ".git")); err != nil { + panic(err) + } + + return osfs.New(worktree) +} + type Fixtures []*Fixture func (g Fixtures) Test(c *check.C, test func(*Fixture)) { |