aboutsummaryrefslogtreecommitdiffstats
path: root/submodule_test.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-05-11 08:02:11 +0100
committerGitHub <noreply@github.com>2023-05-11 08:02:11 +0100
commitdc2b346ed149080199d578f0190f3ac1156480c2 (patch)
tree513a5972fca375657cbf904c4153987e506f8cf0 /submodule_test.go
parent1dbd729a387edb61c89f088cd68040085e6c81bb (diff)
parentb8dd39abcc9dd35808ec625a90a68c0ace4973e4 (diff)
downloadgo-git-dc2b346ed149080199d578f0190f3ac1156480c2.tar.gz
Merge pull request #769 from AriehSchneier/fix-test-clean
git: Testing, Fix tests not cleaning temp folders
Diffstat (limited to 'submodule_test.go')
-rw-r--r--submodule_test.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/submodule_test.go b/submodule_test.go
index a8a0681..92943e1 100644
--- a/submodule_test.go
+++ b/submodule_test.go
@@ -2,7 +2,6 @@ package git
import (
"context"
- "os"
"path/filepath"
"testing"
@@ -15,7 +14,7 @@ import (
type SubmoduleSuite struct {
BaseSuite
Worktree *Worktree
- path string
+ clean func()
}
var _ = Suite(&SubmoduleSuite{})
@@ -23,8 +22,8 @@ var _ = Suite(&SubmoduleSuite{})
func (s *SubmoduleSuite) SetUpTest(c *C) {
path := fixtures.ByTag("submodule").One().Worktree().Root()
- dir, clean := s.TemporalDir()
- defer clean()
+ var dir string
+ dir, s.clean = s.TemporalDir()
r, err := PlainClone(filepath.Join(dir, "worktree"), false, &CloneOptions{
URL: path,
@@ -35,13 +34,10 @@ func (s *SubmoduleSuite) SetUpTest(c *C) {
s.Repository = r
s.Worktree, err = r.Worktree()
c.Assert(err, IsNil)
-
- s.path = dir
}
-func (s *SubmoduleSuite) TearDownTest(c *C) {
- err := os.RemoveAll(s.path)
- c.Assert(err, IsNil)
+func (s *SubmoduleSuite) TearDownTest(_ *C) {
+ s.clean()
}
func (s *SubmoduleSuite) TestInit(c *C) {
@@ -198,7 +194,7 @@ func (s *SubmoduleSuite) TestSubmodulesInit(c *C) {
func (s *SubmoduleSuite) TestGitSubmodulesSymlink(c *C) {
f, err := s.Worktree.Filesystem.Create("badfile")
c.Assert(err, IsNil)
- defer f.Close()
+ defer func() { _ = f.Close() }()
err = s.Worktree.Filesystem.Remove(gitmodulesFile)
c.Assert(err, IsNil)