提交 d0d0ce57 编写于 作者: martianzhang's avatar martianzhang

fix ParseDSN test case

上级 027e992f
...@@ -90,18 +90,20 @@ func TestParseDSN(t *testing.T) { ...@@ -90,18 +90,20 @@ func TestParseDSN(t *testing.T) {
// go-sql-driver dsn // go-sql-driver dsn
"user@unix(/path/to/socket)/dbname", "user@unix(/path/to/socket)/dbname",
"root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local", "root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local",
"user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true", "user:password@tcp(localhost:5555)/dbname?tls=skip-verify",
"user:password@tcp(localhost:5555)/dbname?autocommit=true",
"user:password@/dbname?sql_mode=TRADITIONAL", "user:password@/dbname?sql_mode=TRADITIONAL",
"user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_unicode_ci", "user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s",
"user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?collation=utf8mb4_unicode_ci",
"id:password@tcp(your-amazonaws-uri.com:3306)/dbname", "id:password@tcp(your-amazonaws-uri.com:3306)/dbname",
"user@cloudsql(project-id:instance-name)/dbname", "user@cloudsql(project-id:instance-name)/dbname",
"user@cloudsql(project-id:regionname:instance-name)/dbname", "user@cloudsql(project-id:regionname:instance-name)/dbname",
"user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped", //"user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped", multi key in map, pretty print in random order, by pass
"user:password@tcp/dbname?sys_var=esc%40ped",
"user:password@/dbname", "user:password@/dbname",
"user:password@/", "user:password@/",
"user:password@tcp(localhost:3307)/database?charset=utf8&timeout=5s", "user:password@tcp(localhost:3307)/database?timeout=5s",
} }
err := GoldenDiff(func() { err := GoldenDiff(func() {
for _, dsn := range dsns { for _, dsn := range dsns {
pretty.Println(dsn) pretty.Println(dsn)
......
...@@ -438,7 +438,7 @@ root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local ...@@ -438,7 +438,7 @@ root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local
Disable: false, Disable: false,
Version: 99999, Version: 99999,
} }
user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true user:password@tcp(localhost:5555)/dbname?tls=skip-verify
&common.Dsn{ &common.Dsn{
User: "user", User: "user",
Password: "password", Password: "password",
...@@ -451,6 +451,28 @@ user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true ...@@ -451,6 +451,28 @@ user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true
TLS: "skip-verify", TLS: "skip-verify",
ServerPubKey: "", ServerPubKey: "",
MaxAllowedPacket: 4194304, MaxAllowedPacket: 4194304,
Params: {},
Timeout: "0s",
ReadTimeout: "0s",
WriteTimeout: "0s",
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
Version: 99999,
}
user:password@tcp(localhost:5555)/dbname?autocommit=true
&common.Dsn{
User: "user",
Password: "password",
Net: "tcp",
Addr: "localhost:5555",
Schema: "dbname",
Charset: "utf8",
Collation: "utf8_general_ci",
Loc: "UTC",
TLS: "",
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {"autocommit":"true"}, Params: {"autocommit":"true"},
Timeout: "0s", Timeout: "0s",
ReadTimeout: "0s", ReadTimeout: "0s",
...@@ -482,7 +504,7 @@ user:password@/dbname?sql_mode=TRADITIONAL ...@@ -482,7 +504,7 @@ user:password@/dbname?sql_mode=TRADITIONAL
Disable: false, Disable: false,
Version: 99999, Version: 99999,
} }
user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_unicode_ci user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s
&common.Dsn{ &common.Dsn{
User: "user", User: "user",
Password: "password", Password: "password",
...@@ -490,7 +512,7 @@ user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_ ...@@ -490,7 +512,7 @@ user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_
Addr: "[de:ad:be:ef::ca:fe]:80", Addr: "[de:ad:be:ef::ca:fe]:80",
Schema: "dbname", Schema: "dbname",
Charset: "utf8", Charset: "utf8",
Collation: "utf8mb4_unicode_ci", Collation: "utf8_general_ci",
Loc: "UTC", Loc: "UTC",
TLS: "", TLS: "",
ServerPubKey: "", ServerPubKey: "",
...@@ -504,6 +526,28 @@ user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_ ...@@ -504,6 +526,28 @@ user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_
Disable: false, Disable: false,
Version: 99999, Version: 99999,
} }
user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?collation=utf8mb4_unicode_ci
&common.Dsn{
User: "user",
Password: "password",
Net: "tcp",
Addr: "[de:ad:be:ef::ca:fe]:80",
Schema: "dbname",
Charset: "utf8",
Collation: "utf8mb4_unicode_ci",
Loc: "UTC",
TLS: "",
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout: "0s",
ReadTimeout: "0s",
WriteTimeout: "0s",
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
Version: 99999,
}
id:password@tcp(your-amazonaws-uri.com:3306)/dbname id:password@tcp(your-amazonaws-uri.com:3306)/dbname
&common.Dsn{ &common.Dsn{
User: "id", User: "id",
...@@ -570,20 +614,20 @@ user@cloudsql(project-id:regionname:instance-name)/dbname ...@@ -570,20 +614,20 @@ user@cloudsql(project-id:regionname:instance-name)/dbname
Disable: false, Disable: false,
Version: 99999, Version: 99999,
} }
user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped user:password@tcp/dbname?sys_var=esc%40ped
&common.Dsn{ &common.Dsn{
User: "user", User: "user",
Password: "password", Password: "password",
Net: "tcp", Net: "tcp",
Addr: "127.0.0.1:3306", Addr: "127.0.0.1:3306",
Schema: "dbname", Schema: "dbname",
Charset: "utf8mb4,utf8", Charset: "utf8",
Collation: "utf8_general_ci", Collation: "utf8_general_ci",
Loc: "UTC", Loc: "UTC",
TLS: "", TLS: "",
ServerPubKey: "", ServerPubKey: "",
MaxAllowedPacket: 4194304, MaxAllowedPacket: 4194304,
Params: {"charset":"utf8mb4,utf8", "sys_var":"esc@ped"}, Params: {"sys_var":"esc@ped"},
Timeout: "0s", Timeout: "0s",
ReadTimeout: "0s", ReadTimeout: "0s",
WriteTimeout: "0s", WriteTimeout: "0s",
...@@ -636,7 +680,7 @@ user:password@/ ...@@ -636,7 +680,7 @@ user:password@/
Disable: false, Disable: false,
Version: 99999, Version: 99999,
} }
user:password@tcp(localhost:3307)/database?charset=utf8&timeout=5s user:password@tcp(localhost:3307)/database?timeout=5s
&common.Dsn{ &common.Dsn{
User: "user", User: "user",
Password: "password", Password: "password",
...@@ -649,7 +693,7 @@ user:password@tcp(localhost:3307)/database?charset=utf8&timeout=5s ...@@ -649,7 +693,7 @@ user:password@tcp(localhost:3307)/database?charset=utf8&timeout=5s
TLS: "", TLS: "",
ServerPubKey: "", ServerPubKey: "",
MaxAllowedPacket: 4194304, MaxAllowedPacket: 4194304,
Params: {"charset":"utf8"}, Params: {},
Timeout: "5s", Timeout: "5s",
ReadTimeout: "0s", ReadTimeout: "0s",
WriteTimeout: "0s", WriteTimeout: "0s",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册