mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
improve package gdebug; add more unit testing case for package gdb
This commit is contained in:
@ -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"])
|
||||
})
|
||||
}
|
||||
|
||||
@ -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) &&
|
||||
|
||||
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user