Skip to content

Commit

Permalink
lint: fixup comment style
Browse files Browse the repository at this point in the history
  • Loading branch information
aramprice committed Jul 19, 2024
1 parent ea8e409 commit e2824f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package_stemcell/packagers/vmdk_packager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 8 additions & 15 deletions package_stemcell/stemcell_generator/tar/tar_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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()

Expand Down Expand Up @@ -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
}
Expand All @@ -103,16 +97,15 @@ 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
}
actualContents = append(actualContents, buf.String())
}

Expect(actualContents).To(ConsistOf(expectedContents))
Expect(actualFilenames).To(ConsistOf("firstfile", "secondfile"))

Expect(actualFilenames).To(ConsistOf("first-file", "second-file"))
})
})
})

0 comments on commit e2824f5

Please sign in to comment.