-
Notifications
You must be signed in to change notification settings - Fork 1
/
integration_test.go
50 lines (45 loc) · 1.39 KB
/
integration_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
package gofmcon
import (
"encoding/json"
"github.com/stretchr/testify/assert"
"os"
"testing"
"time"
)
type Table struct {
Text string `json:"text"`
Number float32 `json:"number"`
Date time.Time `json:"date"`
Time time.Time `json:"time"`
Timestamp time.Time `json:"timestamp"`
Container string `json:"container"`
RepeatedContainer []string `json:"repeated_container"`
NotEmptyNumber float32 `json:"not_empty_number"`
SummaryNumber float32 `json:"summary_total_of_number"`
NestedRecords []*NestedTable `json:"nested_table"`
}
type NestedTable struct {
NestedText string `json:"nested_text"`
RepeatedNumber []int `json:"nested_repeated_number"`
}
func Test1(t *testing.T) {
fmHost := os.Getenv("FM_HOST")
fmPort := os.Getenv("FM_PORT")
fmUser := os.Getenv("FM_USER")
fmPass := os.Getenv("FM_PASS")
conn := NewFMConnector(fmHost, fmPort, fmUser, fmPass)
q := NewFMQuery("test", "table", FindAll)
q.WithResponseLayout("table")
res, err := conn.Query(q)
assert.NoError(t, err)
assert.NotNil(t, res)
var tableRecs []Table
for _, record := range res.Resultset.Records {
var tableRec Table
b, err := record.JSONFields()
assert.NoError(t, err)
err = json.Unmarshal(b, &tableRec)
assert.NoError(t, err)
tableRecs = append(tableRecs, tableRec)
}
}