mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-02 23:06:36 +08:00
fb6a3edb89
- Physically purged all legacy internal/ packages, centralized pkg/model/ and pkg/repository/ - Migrated domain models and database repositories into self-contained owner plugins (user, auth, message_gateway, admin, upload, risk_control) - Decoupled cross-plugin interactions via pure core/contracts and typed EventBus - Ensured 100% test coverage pass, zero data races (-race clean), and 0 lint issues in make code-check
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package migrator
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/Rain-kl/Wavelet/pkg/config"
|
|
"github.com/pressly/goose/v3"
|
|
)
|
|
|
|
func TestClickHouseMigrationFilesEmbedded(t *testing.T) {
|
|
entries, err := clickhouseMigrationFS.ReadDir(clickhouseMigrationDir)
|
|
if err != nil {
|
|
t.Fatalf("ReadDir(%q) error = %v", clickhouseMigrationDir, err)
|
|
}
|
|
if len(entries) == 0 {
|
|
t.Fatal("expected embedded ClickHouse migrations, got none")
|
|
}
|
|
|
|
found := false
|
|
for _, entry := range entries {
|
|
if entry.IsDir() {
|
|
continue
|
|
}
|
|
if entry.Name() == "202606190001_create_user_access_logs.sql" {
|
|
found = true
|
|
break
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatal("expected 202606190001_create_user_access_logs.sql in embedded migrations")
|
|
}
|
|
}
|
|
|
|
func TestClickHouseGooseDialect(t *testing.T) {
|
|
if err := goose.SetDialect("clickhouse"); err != nil {
|
|
t.Fatalf("SetDialect(clickhouse) error = %v", err)
|
|
}
|
|
}
|
|
|
|
func TestMigrateClickHouseSkipsWhenDisabled(t *testing.T) {
|
|
previousEnabled := config.Config.ClickHouse.Enabled
|
|
config.Config.ClickHouse.Enabled = false
|
|
t.Cleanup(func() {
|
|
config.Config.ClickHouse.Enabled = previousEnabled
|
|
})
|
|
|
|
MigrateClickHouse()
|
|
}
|