-
Notifications
You must be signed in to change notification settings - Fork 14
/
pusher_postgres_test.go
52 lines (42 loc) · 1.25 KB
/
pusher_postgres_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
package main
import (
"testing"
)
func TestPush(t *testing.T) {
LoadConfig(defaultConf)
cdrFields := []ParseFields{
{OrigField: "uuid", DestField: "callid", TypeField: "string"},
{OrigField: "caller_id_name", DestField: "caller_id_name", TypeField: "string"},
}
config.CDRFields = cdrFields
p := new(PGPusher)
p.Init(config.PGDatasourcename, config.CDRFields, config.SwitchIP, config.CDRSourceType, config.TableDestination)
var err error
// err = p.Connect()
// if err != nil {
// t.Error("Expected error to connect to PostgreSQL")
// }
// err = p.CreateCDRTable()
// if err != nil {
// t.Error("Not expected error, got ", err.Error())
// }
err = p.buildInsertQuery()
if err != nil {
t.Error("Not expected error, got ", err.Error())
}
fetchedResults := make(map[int][]string)
fetchedResults[1] = []string{"myid", "callid", "callerIDname", "string4", "string5"}
fmtres, _ := p.FmtDataExport(fetchedResults)
if fmtres == nil {
t.Error("Expected result, got ", fmtres)
}
// err = p.BatchInsert(fetchedResults)
// if err == nil {
// t.Error("Not expected error, got ", err.Error())
// }
// results := make(map[int][]string)
// err := p.Push(results)
// if err != nil {
// t.Error("Not expected error, got ", err.Error())
// }
}