-
Notifications
You must be signed in to change notification settings - Fork 0
/
saver_test.go
57 lines (52 loc) · 1.25 KB
/
saver_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package go_nets
import (
"fmt"
"os"
"testing"
"code.google.com/p/go.text/encoding/charmap"
)
func init() {
initiateMultiCore(1)
}
func TestSaver(t *testing.T) {
filename := "UMtest2.xml"
fmt.Println("### TESTING the saver (big file)")
Parser := XmlParser{
FileDir: "_test/",
FileName: filename,
Encoding: charmap.Windows1252,
}
TestSaver := &SqlSaver{
DbPath: "_test/",
DbName: filename,
DBDriver: "sqlite3",
}
cs := make(chan Filing)
fi, errOs := os.Create("_test/saver_test_parser.log")
if errOs != nil {
panic(errOs) //TODO change it to t.Error
}
go Parser.Parse(cs, fi)
ListenAndSave(FilingToSaveable(cs), TestSaver)
}
func TestDirectSaver(t *testing.T) { // Gets more than above because of the non-discarded filings with " inside the fields.
filename := "UMtest2.xml"
fmt.Println("### TESTING the saver (big file)")
Parser := XmlParser{
FileDir: "_test/",
FileName: filename,
Encoding: charmap.Windows1252,
}
TestSaver := &SqlSaver{
DbPath: "_test/",
DbName: "direct" + filename,
DBDriver: "sqlite3",
}
cs := make(chan Filing)
fi, errOs := os.Create("_test/saver_test_parser.log")
if errOs != nil {
panic(errOs) //TODO change it to t.Error
}
go Parser.Parse(cs, fi)
ListenAndSaveFilings(cs, TestSaver)
}