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:
@@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user