mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-04 07: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
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package logstore
|
|
|
|
import (
|
|
"os/exec"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// apps 禁止直连 analytics 做日志读写;查询过滤器请用 logstore.AccessLogFilter。
|
|
var forbiddenImports = []string{
|
|
"github.com/Rain-kl/Wavelet/pkg/persistence/analytics",
|
|
}
|
|
|
|
// logstore 的 CH 实现按设计委托 analyticsrepo。
|
|
var allowedAnalyticsDelegation = map[string]bool{
|
|
"github.com/Rain-kl/Wavelet/pkg/persistence/logstore": true,
|
|
}
|
|
|
|
func TestAppsMustNotImportLogBackendDirectly(t *testing.T) {
|
|
t.Chdir("../../..")
|
|
out, err := exec.Command("go", "list", "-test", "-f", `{{.ImportPath}} {{join .Imports " "}}`, "./plugins/domain/...").Output()
|
|
if err != nil {
|
|
t.Fatalf("go list: %v", err)
|
|
}
|
|
for _, line := range strings.Split(string(out), "\n") {
|
|
fields := strings.Fields(line)
|
|
if len(fields) == 0 {
|
|
continue
|
|
}
|
|
pkg := fields[0]
|
|
if !strings.HasPrefix(pkg, "github.com/Rain-kl/Wavelet/plugins/domain") {
|
|
continue
|
|
}
|
|
for _, imp := range fields[1:] {
|
|
for _, forbidden := range forbiddenImports {
|
|
if imp == forbidden && !allowedAnalyticsDelegation[pkg] {
|
|
t.Errorf("%s must not import forbidden log backend %s", pkg, forbidden)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|