mirror of
https://github.com/onyx-and-iris/exclude.git
synced 2026-04-16 14:13:39 +00:00
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:
18
cmd/testhelpers_test.go
Normal file
18
cmd/testhelpers_test.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user