Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitris Karakasilis <[email protected]>
  • Loading branch information
jimmykarily committed Sep 4, 2024
1 parent 8bf8fd8 commit 774547e
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions pkg/action/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var _ = Describe("Runtime Actions", func() {
Expect(err).ToNot(HaveOccurred())
cliConfig := string(d)

config, err := agentConfig.Scan(collector.Directories(), collector.Readers(strings.NewReader(cliConfig)))
config, err := agentConfig.Scan(collector.Readers(strings.NewReader(cliConfig)))
Expect(err).ToNot(HaveOccurred())

agentConfig.WithFs(fs)(config)
Expand Down Expand Up @@ -670,27 +670,15 @@ func createDummyFile(fs vfs.FS, sizeMb int64) string {
tmpFile.Close()
os.RemoveAll(tmpName)

dummyData := []byte("1234567890ABCDEF")
dummyLength := int64(len(dummyData))

var written int64
data := []byte{}
for written < fileSize {
bytesToWrite := dummyLength
if written+bytesToWrite > fileSize {
bytesToWrite = fileSize - written
}
data = append(data, dummyData[:bytesToWrite]...)
Expect(err).ToNot(HaveOccurred())

written += bytesToWrite
}

dir := filepath.Dir(tmpName)
err = fs.Mkdir(dir, os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile(tmpName, data, os.ModePerm)
Expect(err).ToNot(HaveOccurred())

f, err := fs.Create(tmpName)
Expect(err).ShouldNot(HaveOccurred())
err = f.Truncate(fileSize)
Expect(err).ShouldNot(HaveOccurred())
f.Close()

return tmpName
}

0 comments on commit 774547e

Please sign in to comment.