improve package gdebug; add more unit testing case for package gdb

This commit is contained in:
John
2020-04-27 17:56:04 +08:00
parent 9480ffcdc0
commit cf1d3d3d2b
3 changed files with 32 additions and 6 deletions

View File

@ -2324,3 +2324,31 @@ func Test_Model_Min_Max(t *testing.T) {
t.Assert(value.Int(), 10)
})
}
func Test_Model_NullField(t *testing.T) {
table := createTable()
defer dropTable(table)
gtest.C(t, func(t *gtest.T) {
type User struct {
Id int
Passport *string
}
data := g.Map{
"id": 1,
"passport": nil,
}
result, err := db.Table(table).Data(data).Insert()
t.Assert(err, nil)
n, _ := result.RowsAffected()
t.Assert(n, 1)
one, err := db.Table(table).FindOne(1)
t.Assert(err, nil)
var user *User
err = one.Struct(&user)
t.Assert(err, nil)
t.Assert(user.Id, data["id"])
t.Assert(user.Passport, data["passport"])
})
}

View File

@ -58,6 +58,10 @@ func StackWithFilters(filters []string, skip ...int) string {
pc, file, line, ok = runtime.Caller(i)
}
if ok {
// Filter empty file.
if file == "" {
continue
}
// GOROOT filter.
if goRootForFilter != "" &&
len(file) >= len(goRootForFilter) &&

View File

@ -99,9 +99,6 @@ func (view *View) SetPath(path string) error {
isDir = false
realPath = ""
)
if path == "" {
path = "."
}
if file := gres.Get(path); file != nil {
realPath = path
isDir = file.FileInfo().IsDir()
@ -156,9 +153,6 @@ func (view *View) AddPath(path string) error {
isDir = false
realPath = ""
)
if path == "" {
path = "."
}
if file := gres.Get(path); file != nil {
realPath = path
isDir = file.FileInfo().IsDir()