-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert_test.go
53 lines (46 loc) · 1.02 KB
/
insert_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
package neo4j
import (
"github.com/aliworkshop/configer"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
type User struct {
Id uint64 `json:"id"`
Uuid string `json:"uuid"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Age int `json:"age"`
Mobile string `json:"mobile"`
}
func (User) TableName() string {
return "users"
}
func TestNeo_Insert(t *testing.T) {
registry := configer.New()
registry.SetConfigType("yaml")
f, err := os.Open("./config.sample.yaml")
if err != nil {
panic("cannot read config: " + err.Error())
}
err = registry.ReadConfig(f)
if err != nil {
panic("cannot read config" + err.Error())
}
db := NewNeo4jRepository(registry)
err = db.Connect()
assert.Nil(t, err)
defer db.Close()
uuid := uuid.New().String()
u := &User{
Id: 13,
Uuid: uuid,
FirstName: "John",
LastName: "Cena",
Age: 40,
Mobile: "09123456789",
}
err = db.Insert(NewQuery().WithBody(u))
assert.Nil(t, err)
}