mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-09 12:06:35 +00:00
Strip carriage-returns from textfile input
This commit is contained in:
20
collector/textfile_test.go
Normal file
20
collector/textfile_test.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package collector
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"strings"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
func TestCRFilter(t *testing.T) {
|
||||
sr := strings.NewReader("line 1\r\nline 2")
|
||||
cr := carriageReturnFilteringReader{ r: sr }
|
||||
b, err := ioutil.ReadAll(cr)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if string(b) != "line 1\nline 2" {
|
||||
t.Errorf("Unexpected output %q", b)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user