feat: complete 2.0.7.12 platform overhaul
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package health
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"ymhut-box/server/unified-management/internal/config"
|
||||
"ymhut-box/server/unified-management/internal/db"
|
||||
)
|
||||
|
||||
func TestSnapshotReadsCachedPreflightUntilManualRefresh(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
cfg := &config.Config{
|
||||
BaseDir: root, StorageDir: filepath.Join(root, "storage"), DataDir: filepath.Join(root, "data"),
|
||||
UpdatePublicDir: filepath.Join(root, "data", "update", "public"), UpdateNoticeDir: filepath.Join(root, "data", "notices"),
|
||||
DownloadsDir: filepath.Join(root, "data", "update", "public", "downloads"), AdminWebDir: filepath.Join(root, "admin"),
|
||||
PortalWebDir: filepath.Join(root, "portal"), SetupWebDir: filepath.Join(root, "setup"), AdminAssetMode: "disk",
|
||||
Database: config.DatabaseConfig{Provider: "sqlite", SQLitePath: filepath.Join(root, "storage", "health.sqlite"), HealthIntervalSec: 3600},
|
||||
}
|
||||
store, err := db.Open(cfg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer store.Close()
|
||||
service := NewService(cfg, store)
|
||||
if err := os.RemoveAll(cfg.DownloadsDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = service.Snapshot()
|
||||
if _, err := os.Stat(cfg.DownloadsDir); !os.IsNotExist(err) {
|
||||
t.Fatalf("cached snapshot unexpectedly reran filesystem preflight: %v", err)
|
||||
}
|
||||
service.RefreshPreflight()
|
||||
if _, err := os.Stat(cfg.DownloadsDir); err != nil {
|
||||
t.Fatalf("manual refresh did not recreate downloads directory: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user