MCPcopy Index your code
hub / github.com/rclone/rclone / testFilterForEachLine

Function testFilterForEachLine

fs/filter/filter_test.go:741–781  ·  view source on GitHub ↗
(t *testing.T, useStdin, raw bool)

Source from the content-addressed store, hash-verified

739}
740
741func testFilterForEachLine(t *testing.T, useStdin, raw bool) {
742 file := testFile(t, `; comment
743one
744# another comment
745
746
747two
748 # indented comment
749three
750four
751five
752 six `)
753 defer func() {
754 err := os.Remove(file)
755 require.NoError(t, err)
756 }()
757 lines := []string{}
758 fileName := file
759 if useStdin {
760 in, err := os.Open(file)
761 require.NoError(t, err)
762 oldStdin := os.Stdin
763 os.Stdin = in
764 defer func() {
765 os.Stdin = oldStdin
766 _ = in.Close()
767 }()
768 fileName = "-"
769 }
770 err := forEachLine(fileName, raw, func(s string) error {
771 lines = append(lines, s)
772 return nil
773 })
774 require.NoError(t, err)
775 if raw {
776 assert.Equal(t, "; comment,one,# another comment,,,two, # indented comment,three ,four ,five, six ",
777 strings.Join(lines, ","))
778 } else {
779 assert.Equal(t, "one,two,three,four,five,six", strings.Join(lines, ","))
780 }
781}
782
783func TestFilterForEachLine(t *testing.T) {
784 testFilterForEachLine(t, false, false)

Callers 4

TestFilterForEachLineFunction · 0.85

Calls 7

testFileFunction · 0.85
forEachLineFunction · 0.85
JoinMethod · 0.80
RemoveMethod · 0.65
OpenMethod · 0.65
CloseMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…