MCPcopy
hub / github.com/go-sql-driver/mysql / TestCollation

Function TestCollation

driver_test.go:1606–1639  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1604}
1605
1606func TestCollation(t *testing.T) {
1607 if !available {
1608 t.Skipf("MySQL server not running on %s", netAddr)
1609 }
1610
1611 // MariaDB may override collation specified by handshake with `character_set_collations` variable.
1612 // https://mariadb.com/kb/en/setting-character-sets-and-collations/#changing-default-collation
1613 // https://mariadb.com/kb/en/server-system-variables/#character_set_collations
1614 // utf8mb4_general_ci, utf8mb3_general_ci will be overridden by default MariaDB.
1615 // Collations other than charasets default are not overridden. So utf8mb4_unicode_ci is safe.
1616 testCollations := []string{
1617 "latin1_general_ci",
1618 "binary",
1619 "utf8mb4_unicode_ci",
1620 "cp1257_bin",
1621 }
1622
1623 for _, collation := range testCollations {
1624 t.Run(collation, func(t *testing.T) {
1625 tdsn := dsn + "&collation=" + collation
1626 expected := collation
1627
1628 runTests(t, tdsn, func(dbt *DBTest) {
1629 var got string
1630 if err := dbt.db.QueryRow("SELECT @@collation_connection").Scan(&got); err != nil {
1631 dbt.Fatal(err)
1632 }
1633 if got != expected {
1634 dbt.Fatalf("expected connection collation %s but got %s", expected, got)
1635 }
1636 })
1637 })
1638 }
1639}
1640
1641func TestColumnsWithAlias(t *testing.T) {
1642 runTestsParallel(t, dsn+"&columnsWithAlias=true", func(dbt *DBTest, _ string) {

Callers

nothing calls this directly

Calls 2

runTestsFunction · 0.85
ScanMethod · 0.80

Tested by

no test coverage detected