forked from astaxie/beedb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil_test.go
More file actions
39 lines (33 loc) · 748 Bytes
/
util_test.go
File metadata and controls
39 lines (33 loc) · 748 Bytes
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
package beedb
import (
"testing"
"time"
)
type User struct {
SQLModel `sql:",inline"`
Name string `sql:"name" tname:"fn_group"`
Auth int `sql:"auth"`
}
type SQLModel struct {
Id int `beedb:"PK" sql:"id"`
Created time.Time `sql:"created"`
Modified time.Time `sql:"modified"`
}
func TestMapToStruct(t *testing.T) {
target := &User{}
input := map[string][]byte{
"name": []byte("Test User"),
"auth": []byte("1"),
"id": []byte("1"),
"created": []byte("2014-01-01 10:10:10"),
"modified": []byte("2014-01-01 10:10:10"),
}
err := scanMapIntoStruct(target, input)
if err != nil {
t.Errorf(err.Error())
}
_, err = scanStructIntoMap(target)
if err != nil {
t.Errorf(err.Error())
}
}