Files
mire/internal/miro/post_process_test.go

51 lines
1.2 KiB
Go

package miro
import (
"path/filepath"
"testing"
)
func TestLoadRecordedInputTrimsTrailingNewlineAfterEOF(t *testing.T) {
path := filepath.Join(t.TempDir(), "in")
writeFile(t, path, "echo hi\r"+string([]byte{eofByte})+"\n")
got, err := loadRecordedInput(path)
if err != nil {
t.Fatalf("loadRecordedInput() error = %v", err)
}
want := "echo hi\r" + string([]byte{eofByte})
if string(got) != want {
t.Fatalf("loadRecordedInput() = %q, want %q", string(got), want)
}
}
func TestLoadRecordedInputTrimsTrailingNewlineAfterCarriageReturn(t *testing.T) {
path := filepath.Join(t.TempDir(), "in")
writeFile(t, path, "echo hi\rexit\r\n")
got, err := loadRecordedInput(path)
if err != nil {
t.Fatalf("loadRecordedInput() error = %v", err)
}
want := "echo hi\rexit\r"
if string(got) != want {
t.Fatalf("loadRecordedInput() = %q, want %q", string(got), want)
}
}
func TestLoadRecordedInputLeavesNormalTrailingNewline(t *testing.T) {
path := filepath.Join(t.TempDir(), "in")
writeFile(t, path, "echo hi\n")
got, err := loadRecordedInput(path)
if err != nil {
t.Fatalf("loadRecordedInput() error = %v", err)
}
if string(got) != "echo hi\n" {
t.Fatalf("loadRecordedInput() = %q, want %q", string(got), "echo hi\n")
}
}