github.com/sereiner/library@v0.0.0-20200518095232-1fa3e640cc5f/db/tpl/tpl_tpl_test.go (about) 1 package tpl 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func TestTplxx(t *testing.T) { 9 sql, _, _ := AnalyzeTPL("where &id", map[string]interface{}{ 10 "id": 1, 11 }, func() string { 12 return "1" 13 }) 14 fmt.Println("sql:", sql) 15 } 16 17 func TestORCLContext(t *testing.T) { 18 context, err := GetDBContext("ORACLE") 19 if err != nil || context == nil { 20 t.Error("GetDBContext返回结果有误") 21 } 22 23 context, err = GetDBContext("oracle") 24 if err != nil || context == nil { 25 t.Error("GetDBContext返回结果有误") 26 } 27 28 context, err = GetDBContext("sqlite") 29 if err != nil || context == nil { 30 t.Error("GetDBContext返回结果有误") 31 } 32 33 context, err = GetDBContext("SQLITE") 34 if err != nil || context == nil { 35 t.Error("GetDBContext返回结果有误") 36 } 37 38 context, err = GetDBContext("mysql2") 39 if err == nil || context != nil { 40 t.Error("GetDBContext返回结果有误") 41 } 42 43 /*add by champly 2016年11月9日11:54:20*/ 44 // 输入不同的字符 45 context, err = GetDBContext("#@!%¥%") 46 if err == nil || context != nil { 47 t.Error("GetDBContext返回结果有误") 48 } 49 50 // 输入空字符 51 context, err = GetDBContext("") 52 if err == nil || context != nil { 53 t.Error("GetDBContext返回结果有误") 54 } 55 /*end*/ 56 }