From 2943b8396fedc6ba7c6929589311f1f4ad07a587 Mon Sep 17 00:00:00 2001 From: Eileen Yu Date: Sun, 28 Jan 2024 23:09:28 -0500 Subject: [PATCH] fix: drop unnecessary file change for unit test --- pkg/plugin/util/testdata/exampleFile.txt | 2 +- pkg/plugin/util/util_test.go | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/plugin/util/testdata/exampleFile.txt b/pkg/plugin/util/testdata/exampleFile.txt index 49f76e16e87..a1e0fa03605 100644 --- a/pkg/plugin/util/testdata/exampleFile.txt +++ b/pkg/plugin/util/testdata/exampleFile.txt @@ -1 +1 @@ -exampleTargetexampleCodeexampleCodeexampleCodeexampleCodeexampleCodeexampleCodeexampleCodeexampleCode \ No newline at end of file +exampleTarget diff --git a/pkg/plugin/util/util_test.go b/pkg/plugin/util/util_test.go index be910c848be..e502934a606 100644 --- a/pkg/plugin/util/util_test.go +++ b/pkg/plugin/util/util_test.go @@ -14,14 +14,28 @@ limitations under the License. package util import ( + "os" "path/filepath" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) -var _ = Describe("InsertCode", func() { +var _ = Describe("InsertCode", Ordered, func() { path := filepath.Join("testdata", "exampleFile.txt") + var originalContent []byte + + BeforeAll(func() { + var err error + originalContent, err = os.ReadFile(path) + Expect(err).NotTo(HaveOccurred()) + }) + + AfterAll(func() { + err := os.WriteFile(path, originalContent, 0644) + Expect(err).NotTo(HaveOccurred()) + }) + DescribeTable("should not succeed", func(target string) { Expect(InsertCode(path, target, "exampleCode")).ShouldNot(Succeed())