|
|
|
package stardb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Useless struct {
|
|
|
|
Leader string `db:"leader"`
|
|
|
|
Usable bool `db:"use"`
|
|
|
|
O *Whoami `db:"---"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Whoami struct {
|
|
|
|
Hehe string `db:"hehe"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUpInOrm(t *testing.T) {
|
|
|
|
var hehe = Useless{
|
|
|
|
Leader: "no",
|
|
|
|
Usable: false,
|
|
|
|
}
|
|
|
|
sqlstr, param, err := getUpdateSentence(hehe, "ryz", "leader")
|
|
|
|
fmt.Println(sqlstr, param, err)
|
|
|
|
sqlstr, param, err = getInsertSentence(hehe, "ryz", "use")
|
|
|
|
fmt.Println(sqlstr, param, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_SetRefVal(t *testing.T) {
|
|
|
|
var hehe = Useless{
|
|
|
|
Leader: "no",
|
|
|
|
}
|
|
|
|
fmt.Printf("%+v\n", hehe)
|
|
|
|
fmt.Println(setRefValue(&hehe, "db", "leader", "sb"))
|
|
|
|
fmt.Printf("%+v\n", hehe)
|
|
|
|
fmt.Printf("%+v\n", hehe)
|
|
|
|
fmt.Println(getAllRefKey(hehe, "db"))
|
|
|
|
fmt.Println(getAllRefValue(hehe, "db"))
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_Ref(t *testing.T) {
|
|
|
|
oooooo := Useless{
|
|
|
|
Leader: "Heheeee",
|
|
|
|
}
|
|
|
|
oooooo.O = &Whoami{"fuck"}
|
|
|
|
fmt.Println(getAllRefKey(oooooo, "db"))
|
|
|
|
fmt.Println(getAllRefValue(oooooo, "db"))
|
|
|
|
fmt.Println(getAllRefValue(&oooooo, "db"))
|
|
|
|
}
|