Skip to content

Commit 7720487

Browse files
authored
[pkg/stanza] Remove duplicate test (#12090)
1 parent c013abc commit 7720487

File tree

2 files changed

+1
-95
lines changed

2 files changed

+1
-95
lines changed

pkg/stanza/fileconsumer/file_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,14 +1081,7 @@ func TestEncodings(t *testing.T) {
10811081
require.NoError(t, operator.Stop())
10821082
}()
10831083

1084-
for _, expected := range tc.expected {
1085-
select {
1086-
case call := <-emitCalls:
1087-
require.Equal(t, expected, call.token)
1088-
case <-time.After(500 * time.Millisecond):
1089-
require.FailNow(t, "Timed out waiting for entry to be read")
1090-
}
1091-
}
1084+
waitForTokens(t, emitCalls, tc.expected)
10921085
})
10931086
}
10941087
}

pkg/stanza/operator/input/file/file_test.go

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -753,90 +753,3 @@ func TestManyLogsDelivered(t *testing.T) {
753753
}
754754
expectNoMessages(t, logReceived)
755755
}
756-
757-
func TestEncodings(t *testing.T) {
758-
t.Parallel()
759-
cases := []struct {
760-
name string
761-
contents []byte
762-
encoding string
763-
expected [][]byte
764-
}{
765-
{
766-
"Nop",
767-
[]byte{0xc5, '\n'},
768-
"",
769-
[][]byte{{0xc5}},
770-
},
771-
{
772-
"InvalidUTFReplacement",
773-
[]byte{0xc5, '\n'},
774-
"utf8",
775-
[][]byte{{0xef, 0xbf, 0xbd}},
776-
},
777-
{
778-
"ValidUTF8",
779-
[]byte("foo\n"),
780-
"utf8",
781-
[][]byte{[]byte("foo")},
782-
},
783-
{
784-
"ChineseCharacter",
785-
[]byte{230, 138, 152, '\n'}, // 折\n
786-
"utf8",
787-
[][]byte{{230, 138, 152}},
788-
},
789-
{
790-
"SmileyFaceUTF16",
791-
[]byte{216, 61, 222, 0, 0, 10}, // 😀\n
792-
"utf-16be",
793-
[][]byte{{240, 159, 152, 128}},
794-
},
795-
{
796-
"SmileyFaceNewlineUTF16",
797-
[]byte{216, 61, 222, 0, 0, 10, 0, 102, 0, 111, 0, 111}, // 😀\nfoo
798-
"utf-16be",
799-
[][]byte{{240, 159, 152, 128}, {102, 111, 111}},
800-
},
801-
{
802-
"SmileyFaceNewlineUTF16LE",
803-
[]byte{61, 216, 0, 222, 10, 0, 102, 0, 111, 0, 111, 0}, // 😀\nfoo
804-
"utf-16le",
805-
[][]byte{{240, 159, 152, 128}, {102, 111, 111}},
806-
},
807-
{
808-
"ChineseCharacterBig5",
809-
[]byte{167, 233, 10}, // 折\n
810-
"big5",
811-
[][]byte{{230, 138, 152}},
812-
},
813-
}
814-
815-
for _, tc := range cases {
816-
t.Run(tc.name, func(t *testing.T) {
817-
t.Parallel()
818-
operator, receivedEntries, tempDir := newTestFileOperator(t, func(cfg *Config) {
819-
cfg.Splitter.EncodingConfig = helper.EncodingConfig{Encoding: tc.encoding}
820-
}, nil)
821-
822-
// Popualte the file
823-
temp := openTemp(t, tempDir)
824-
_, err := temp.Write(tc.contents)
825-
require.NoError(t, err)
826-
827-
require.NoError(t, operator.Start(testutil.NewMockPersister("test")))
828-
defer func() {
829-
require.NoError(t, operator.Stop())
830-
}()
831-
832-
for _, expected := range tc.expected {
833-
select {
834-
case entry := <-receivedEntries:
835-
require.Equal(t, expected, []byte(entry.Body.(string)))
836-
case <-time.After(500 * time.Millisecond):
837-
require.FailNow(t, "Timed out waiting for entry to be read")
838-
}
839-
}
840-
})
841-
}
842-
}

0 commit comments

Comments
 (0)