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

View File

@@ -2,27 +2,23 @@ package cmd
import (
"bytes"
"io"
"testing"
)
func TestRunResetCommand(t *testing.T) {
var buf bytes.Buffer
var out bytes.Buffer
var f seekBuffer
if err := resetAndWriteExcludeFile(&buf, &buf); err != nil {
if err := resetAndWriteExcludeFile(&out, &f); err != nil {
t.Fatalf("resetAndWriteExcludeFile failed: %v", err)
}
resetContent, err := io.ReadAll(&buf)
if err != nil {
t.Fatalf("failed to read from temp file: %v", err)
}
if string(resetContent) != defaultExcludeFileContent {
if f.String() != defaultExcludeFileContent {
t.Errorf(
"unexpected content after reset:\nGot:\n%s\nExpected:\n%s",
string(resetContent),
f.String(),
defaultExcludeFileContent,
)
}
}