From e2824f571a74daf11d72a5216d8bac3ec924ddf7 Mon Sep 17 00:00:00 2001 From: aram price Date: Fri, 19 Jul 2024 15:43:52 -0700 Subject: [PATCH] lint: fixup comment style --- package_stemcell/packagers/vmdk_packager.go | 2 +- .../stemcell_generator/tar/tar_writer_test.go | 23 +++++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/package_stemcell/packagers/vmdk_packager.go b/package_stemcell/packagers/vmdk_packager.go index 29c22b44..8f74d35a 100644 --- a/package_stemcell/packagers/vmdk_packager.go +++ b/package_stemcell/packagers/vmdk_packager.go @@ -254,7 +254,7 @@ func (c *VmdkPackager) ConvertVMX2OVA(vmx, ova string) error { return nil } -// CreateImage, converts a vmdk to a gzip compressed image file and records the +// CreateImage converts a vmdk to a gzip compressed image file and records the // sha1 sum of the resulting image. func (c *VmdkPackager) CreateImage() error { c.Debugf("Creating [image] from [vmdk]: %s", c.BuildOptions.VMDKFile) diff --git a/package_stemcell/stemcell_generator/tar/tar_writer_test.go b/package_stemcell/stemcell_generator/tar/tar_writer_test.go index 55d54ae7..2f0b6047 100644 --- a/package_stemcell/stemcell_generator/tar/tar_writer_test.go +++ b/package_stemcell/stemcell_generator/tar/tar_writer_test.go @@ -23,10 +23,7 @@ var _ = Describe("TarWriter", func() { ) BeforeEach(func() { - tmpDir := os.TempDir() - var err error - workingDir, err = os.MkdirTemp(tmpDir, "TarWriterTest") - Expect(err).NotTo(HaveOccurred()) + workingDir = GinkgoT().TempDir() // automatically cleaned up fakeFile := bytes.NewReader([]byte{}) fakeTarable = &tarfakes.FakeTarable{} @@ -35,10 +32,6 @@ var _ = Describe("TarWriter", func() { fakeTarable.NameReturns("some-file") }) - AfterEach(func() { - os.RemoveAll(workingDir) - }) - It("should not fail", func() { w := tar.NewTarWriter() @@ -74,27 +67,28 @@ var _ = Describe("TarWriter", func() { fakeTarable1.ReadStub = fakeFile1.Read fakeTarable1.SizeStub = fakeFile1.Size - fakeTarable1.NameReturns("firstfile") + fakeTarable1.NameReturns("first-file") fakeTarable2.ReadStub = fakeFile2.Read fakeTarable2.SizeStub = fakeFile2.Size - fakeTarable2.NameReturns("secondfile") + fakeTarable2.NameReturns("second-file") err := os.Chdir(workingDir) Expect(err).NotTo(HaveOccurred()) err = w.Write("some-zipped-tar", fakeTarable1, fakeTarable2) //nolint:ineffassign,staticcheck + Expect(err).NotTo(HaveOccurred()) var fileReader, _ = os.OpenFile("some-zipped-tar", os.O_RDONLY, 0777) gzr, err := gzip.NewReader(fileReader) Expect(err).ToNot(HaveOccurred()) defer gzr.Close() - tarfileReader := archiveTar.NewReader(gzr) + tarReader := archiveTar.NewReader(gzr) var actualContents []string var actualFilenames []string for { - header, err := tarfileReader.Next() + header, err := tarReader.Next() if err == io.EOF { break } @@ -103,7 +97,7 @@ var _ = Describe("TarWriter", func() { Expect(header.Mode).To(Equal(int64(os.FileMode(0644)))) buf := new(bytes.Buffer) - _, err = buf.ReadFrom(tarfileReader) + _, err = buf.ReadFrom(tarReader) if err != nil { break } @@ -111,8 +105,7 @@ var _ = Describe("TarWriter", func() { } Expect(actualContents).To(ConsistOf(expectedContents)) - Expect(actualFilenames).To(ConsistOf("firstfile", "secondfile")) - + Expect(actualFilenames).To(ConsistOf("first-file", "second-file")) }) }) })