mirror of
https://github.com/go-gitea/gitea
synced 2025-07-05 10:07:22 +00:00
Refactor renders (#15175)
* Refactor renders * Some performance optimization * Fix comment * Transform reader * Fix csv test * Fix test * Fix tests * Improve optimaziation * Fix test * Fix test * Detect file encoding with reader * Improve optimaziation * reduce memory usage * improve code * fix build * Fix test * Fix for go1.15 * Fix render * Fix comment * Fix lint * Fix test * Don't use NormalEOF when unnecessary * revert change on util.go * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * rename function * Take NormalEOF back Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
@ -5,20 +5,23 @@
|
||||
package csv
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCreateReader(t *testing.T) {
|
||||
rd := CreateReader([]byte{}, ',')
|
||||
rd := CreateReader(bytes.NewReader([]byte{}), ',')
|
||||
assert.Equal(t, ',', rd.Comma)
|
||||
}
|
||||
|
||||
func TestCreateReaderAndGuessDelimiter(t *testing.T) {
|
||||
input := "a;b;c\n1;2;3\n4;5;6"
|
||||
|
||||
rd := CreateReaderAndGuessDelimiter([]byte(input))
|
||||
rd, err := CreateReaderAndGuessDelimiter(strings.NewReader(input))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, ';', rd.Comma)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user