mssqlbulkloader/readerdbf_test.go
2023-04-03 19:12:30 +05:00

39 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"io"
"os"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestDbfReaderBasic(t *testing.T) {
f, err := os.Open("testdata/dbf/38_052QB.dbf")
assert.NoError(t, err)
options := &Options{
fieldsTypes: "sssssstdffsss",
timezone: time.Local,
encoding: "cp866"}
dbfReader, err := NewDbfReader(f, options)
assert.NoError(t, err)
assert.Equal(t, []string{"TRAN_ID", "БАНК", "ОТДЕЛЕНИЕ", "ТОЧКА", "НАЗВАНИЕ", "ТЕРМИНАЛ", АТА_ТРАН", АТА_РАСЧ", "СУММА_ТРАН", "СУММА_РАСЧ", "КАРТА", "КОД_АВТ", "ТИП"}, dbfReader.GetHeader())
row, err := dbfReader.GetRow(false)
assert.NoError(t, err)
t1 := time.Date(2023, 02, 20, 5, 57, 12, 0, time.Local)
t2 := time.Date(2023, 02, 21, 0, 0, 0, 0, time.Local)
assert.Equal(t, []any{"719089383780", "44", "8644", "570000009312", "STOLOVAYA TSPP", "844417", t1, t2, 1757.08, 1713.15, "536829XXXXXX9388", "UM1TS8", "D"}, row)
row, err = dbfReader.GetRow(false)
assert.Equal(t, err, io.EOF)
err = dbfReader.Close()
assert.NoError(t, err)
}