github.com/qxnw/lib4go@v0.0.0-20180426074627-c80c7e84b925/db/tpl/tpl_tpl_test.go (about) 1 package tpl 2 3 import "testing" 4 5 func TestORCLContext(t *testing.T) { 6 context, err := GetDBContext("ORACLE") 7 if err != nil || context == nil { 8 t.Error("GetDBContext返回结果有误") 9 } 10 11 context, err = GetDBContext("oracle") 12 if err != nil || context == nil { 13 t.Error("GetDBContext返回结果有误") 14 } 15 16 context, err = GetDBContext("sqlite") 17 if err != nil || context == nil { 18 t.Error("GetDBContext返回结果有误") 19 } 20 21 context, err = GetDBContext("SQLITE") 22 if err != nil || context == nil { 23 t.Error("GetDBContext返回结果有误") 24 } 25 26 context, err = GetDBContext("mysql2") 27 if err == nil || context != nil { 28 t.Error("GetDBContext返回结果有误") 29 } 30 31 /*add by champly 2016年11月9日11:54:20*/ 32 // 输入不同的字符 33 context, err = GetDBContext("#@!%¥%") 34 if err == nil || context != nil { 35 t.Error("GetDBContext返回结果有误") 36 } 37 38 // 输入空字符 39 context, err = GetDBContext("") 40 if err == nil || context != nil { 41 t.Error("GetDBContext返回结果有误") 42 } 43 /*end*/ 44 }