simplify del/reset commands by using readWriteTruncater interface.

remove the type assertions

update the tests:
the tests now check output as well as file contents separately.
This commit is contained in:
2026-04-07 01:22:56 +01:00
parent c2eab8576e
commit a149ce347b
7 changed files with 86 additions and 89 deletions

18
cmd/testhelpers_test.go Normal file
View File

@@ -0,0 +1,18 @@
package cmd
import "bytes"
// seekBuffer wraps bytes.Buffer to satisfy the readWriteTruncater interface,
// allowing it to be used in place of *os.File in tests.
type seekBuffer struct {
bytes.Buffer
}
func (s *seekBuffer) Seek(offset int64, whence int) (int64, error) {
return 0, nil
}
func (s *seekBuffer) Truncate(size int64) error {
s.Buffer.Reset()
return nil
}