forked from kintone-labs/cli-kintone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport-with-bulkRequest_test.go
48 lines (41 loc) · 1.13 KB
/
import-with-bulkRequest_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
package main
import (
"bytes"
"testing"
"github.com/kintone/go-kintone"
)
func TestImport1(t *testing.T) {
data := "Text,Text_Area,Rich_text\n11,22,<div>aaaaaa</div>\n111,22,<div>dddddqqddss</div>\n211,22,<div>aaaaaa</div>"
app := newApp()
config.DeleteAll = true
err := importFromCSV(app, bytes.NewBufferString(data))
if err != nil {
t.Fatal(err)
}
recs, err := app.GetRecords(nil, "order by $id desc")
if err != nil {
t.Error(err)
}
if len(recs) != 3 {
t.Error("Invalid record count")
}
fields := recs[0].Fields
if _, ok := fields["Text"].(kintone.SingleLineTextField); !ok {
t.Error("Not a SingleLineTextField")
}
if fields["Text"] != kintone.SingleLineTextField("211") {
t.Error("Text mismatch")
}
if _, ok := fields["Text_Area"].(kintone.MultiLineTextField); !ok {
t.Error("Not a MultiLineTextField")
}
if fields["Text_Area"] != kintone.MultiLineTextField("22") {
t.Error("Text_Area mismatch")
}
if _, ok := fields["Rich_text"].(kintone.RichTextField); !ok {
t.Error("Not a RichTextField")
}
if fields["Rich_text"] != kintone.RichTextField("<div>aaaaaa</div>") {
t.Error("Rich_text mismatch")
}
}