mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-01 22:46:38 +08:00
fbbb75095f
Move process wiring, technical adapters, and cross-cutting contracts out of flat internal/ packages so new code has a clear home without changing business layout.
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/internal/infra/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()
|
|
}
|