(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func TestIsTextFile_ByteSniffing(t *testing.T) { |
| 120 | t.Parallel() |
| 121 | tmpDir := t.TempDir() |
| 122 | |
| 123 | // File with unknown extension but text content |
| 124 | textFile := filepath.Join(tmpDir, "data.custom") |
| 125 | err := os.WriteFile(textFile, []byte("This is plain text content\nwith multiple lines\n"), 0o644) |
| 126 | require.NoError(t, err) |
| 127 | assert.True(t, IsTextFile(textFile), "text content with unknown extension should be detected as text") |
| 128 | |
| 129 | // File with unknown extension and binary content (null bytes) |
| 130 | binFile := filepath.Join(tmpDir, "data.custom2") |
| 131 | err = os.WriteFile(binFile, []byte{0x00, 0x01, 0x02, 0x03, 0xFF}, 0o644) |
| 132 | require.NoError(t, err) |
| 133 | assert.False(t, IsTextFile(binFile), "binary content should not be detected as text") |
| 134 | |
| 135 | // Empty file should be treated as text |
| 136 | emptyFile := filepath.Join(tmpDir, "empty.custom") |
| 137 | err = os.WriteFile(emptyFile, []byte{}, 0o644) |
| 138 | require.NoError(t, err) |
| 139 | assert.True(t, IsTextFile(emptyFile), "empty file should be treated as text") |
| 140 | } |
| 141 | |
| 142 | func TestReadFileForInline(t *testing.T) { |
| 143 | t.Parallel() |
nothing calls this directly
no test coverage detected