summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2020-10-22 06:30:31 -0700
committerGitHub <[email protected]>2020-10-22 06:30:31 -0700
commit3a4204bd934b59a55581d33d300617a4f621257f (patch)
tree071d4d493847dbb90e02d269cb81746b22319699
parent5b6ce70b8997254ce48f8c24ba4198080e646fdd (diff)
Make `TestApplyDiffAddFile()` explicitly `.Free()` stuff (#661)
This change adds explicit `.Free()` calls in `TestApplyDiffAddFile()`. It was discovered in #657 that some objects were not explicitly being freed, so this fixes that!
-rw-r--r--diff_test.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/diff_test.go b/diff_test.go
index 394a4c1..e440206 100644
--- a/diff_test.go
+++ b/diff_test.go
@@ -246,11 +246,16 @@ func TestApplyDiffAddfile(t *testing.T) {
seedTestRepo(t, repo)
- addFirstFileCommit, addFileTree := addAndGetTree(t, repo, "file1", `hello`)
+ addFirstFileCommit, addFirstFileTree := addAndGetTree(t, repo, "file1", `hello`)
+ defer addFirstFileCommit.Free()
+ defer addFirstFileTree.Free()
addSecondFileCommit, addSecondFileTree := addAndGetTree(t, repo, "file2", `hello2`)
+ defer addSecondFileCommit.Free()
+ defer addSecondFileTree.Free()
- diff, err := repo.DiffTreeToTree(addFileTree, addSecondFileTree, nil)
+ diff, err := repo.DiffTreeToTree(addFirstFileTree, addSecondFileTree, nil)
checkFatal(t, err)
+ defer diff.Free()
t.Run("check does not apply to current tree because file exists", func(t *testing.T) {
err = repo.ResetToCommit(addSecondFileCommit, ResetHard, &CheckoutOpts{})
@@ -293,12 +298,15 @@ func TestApplyDiffAddfile(t *testing.T) {
commit, err := repo.LookupCommit(head.Target())
checkFatal(t, err)
+ defer commit.Free()
tree, err := commit.Tree()
checkFatal(t, err)
+ defer tree.Free()
- newDiff, err := repo.DiffTreeToTree(addFileTree, tree, nil)
+ newDiff, err := repo.DiffTreeToTree(addFirstFileTree, tree, nil)
checkFatal(t, err)
+ defer newDiff.Free()
raw1b, err := diff.ToBuf(DiffFormatPatch)
checkFatal(t, err)
@@ -327,6 +335,7 @@ func TestApplyDiffAddfile(t *testing.T) {
diff2, err := DiffFromBuffer(raw, repo)
checkFatal(t, err)
+ defer diff2.Free()
err = repo.ApplyDiff(diff2, ApplyLocationBoth, nil)
checkFatal(t, err)