阶段十:完成 Go DB 注释基线清零
This commit is contained in:
1 parent
c47271ae9c
commit
668a4ed3f3
46 files changed
+3030
-19464
No files matched your search
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
// TestParseDBURL 覆盖各 scheme 与向后兼容路径。
|
||||
func TestParseDBURL(t *testing.T) {
|
||||
// cases 保存cases,供当前处理流程使用
|
||||
cases := []struct {
|
||||
name string
|
||||
url string
|
||||
@@ -31,8 +32,10 @@ func TestParseDBURL(t *testing.T) {
|
||||
{name: "whitespace url", url: " ", wantErr: true, errMatch: "为空"},
|
||||
{name: "unknown scheme", url: "redis://h:6379", wantErr: true, errMatch: "不支持"},
|
||||
}
|
||||
// c 表示当前遍历过程中的c
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
// driver、dialect、dsn、err 保存driver、dialect、dsn、err,供当前处理流程使用
|
||||
driver, dialect, dsn, err := parseDBURL(c.url)
|
||||
if c.wantErr {
|
||||
if err == nil {
|
||||
@@ -83,6 +86,7 @@ func TestMysqlDSN(t *testing.T) {
|
||||
|
||||
// TestRewriteQuestionPlaceholders ? → $N,跳过引号内字面量。
|
||||
func TestRewriteQuestionPlaceholders(t *testing.T) {
|
||||
// cases 保存cases,供当前处理流程使用
|
||||
cases := []struct {
|
||||
name string
|
||||
in string
|
||||
@@ -96,8 +100,10 @@ func TestRewriteQuestionPlaceholders(t *testing.T) {
|
||||
{name: "double-quoted identifier with ?", in: `SELECT "col?" FROM t WHERE id=?`, want: `SELECT "col?" FROM t WHERE id=$1`},
|
||||
{name: "empty", in: "", want: ""},
|
||||
}
|
||||
// c 表示当前遍历过程中的c
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
// got 保存got,供当前处理流程使用
|
||||
got := rewriteQuestionPlaceholders(c.in)
|
||||
if got != c.want {
|
||||
t.Errorf("rewriteQuestionPlaceholders(%q)=%q want %q", c.in, got, c.want)
|
||||
|
||||
Reference in new issue
Block a user