fix: support utf8mb4 across MySQL and MariaDB
This commit is contained in:
1 parent
cce17c5fa4
commit
d34894c9cd
28 files changed
+224
-121
No files matched your search
@@ -10,6 +10,7 @@ import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -19,6 +20,29 @@ func itRecord(zone, name, typ, content string, ttl int64) recordRow {
|
||||
return recordRow{Zone: zone, Name: name, TTL: sql.NullInt64{Int64: ttl, Valid: true}, Content: sql.NullString{String: content, Valid: true}, RecordType: typ}
|
||||
}
|
||||
|
||||
func TestIntegrationZoneMatchingWithTurkishCollation(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := t.Context()
|
||||
ddl := strings.Replace(itRecordsDDL, "DEFAULT CHARSET = utf8mb4", "DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_turkish_ci", 1)
|
||||
d := newITDatabase(t, itOptions{prefix: "dns_", recordDDL: ddl})
|
||||
db, tn := d.migrated(t)
|
||||
records := newRecordStore(db, tn)
|
||||
const content = `{"text":"DNS 🌐"}`
|
||||
for _, zone := range []string{"ISTANBUL.example", "istanbul.example."} {
|
||||
if _, err := records.InsertRecord(ctx, itRecord(zone, "", "TXT", content, 60)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
zones, err := records.ListZones(ctx)
|
||||
if err != nil || len(zones) != 1 || zones[0].Zone != "istanbul.example." || zones[0].RecordCount != 2 {
|
||||
t.Fatalf("zones: %+v, %v", zones, err)
|
||||
}
|
||||
rows, err := records.ZoneRows(ctx, "istanbul.example.")
|
||||
if err != nil || len(rows) != 2 || rows[0].Content.String != content {
|
||||
t.Fatalf("records: %+v, %v", rows, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntegrationRecordStore(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
@@ -519,7 +543,7 @@ func TestIntegrationAuditStore(t *testing.T) {
|
||||
}
|
||||
}
|
||||
rows, err := s.ListAudit(ctx, auditFilter{Operation: "user_create", Limit: 1})
|
||||
if err != nil || len(rows) != 1 || rows[0].TargetUsername.String != "carl" || rows[0].UserID.Valid || rows[0].Status.Valid || string(rows[0].After) != `{"id": 3}` || rows[0].Before != nil || !rows[0].Time.Equal(base.Add(4*time.Second)) {
|
||||
if err != nil || len(rows) != 1 || rows[0].TargetUsername.String != "carl" || rows[0].UserID.Valid || rows[0].Status.Valid || string(rows[0].After) != `{"id":3}` || rows[0].Before != nil || !rows[0].Time.Equal(base.Add(4*time.Second)) {
|
||||
t.Fatalf("%+v %v", rows, err)
|
||||
}
|
||||
if _, err := newDelegationStore(db, tn).RevokeDelegation(ctx, "a.org.", bob.ID); err != nil {
|
||||
|
||||
Reference in new issue
Block a user