mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-28 11:16:37 +08:00
b0fe40142a
* Rebrand MMTL to MeBox across codebase and assets Rename the project display name, Go module path, environment variable prefix (MEBOX_*), Docker image references, and UI branding from MMTL/mmtl to MeBox/mebox. Replace logo assets with the new MeBox icon and keep legacy SQLite migration support for existing mmtl.db deployments. Co-authored-by: truewhile <truewhile@users.noreply.github.com> * Fix logo icons: use cube-only crop without truncated text Previous icon generation cropped too much of the source image, including partial MeBox wordmark text that was cut off in square icon containers. Regenerate logo-64/192/512, favicon, and SVG from cube-only region. Co-authored-by: truewhile <truewhile@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: truewhile <truewhile@users.noreply.github.com>
63 lines
1.7 KiB
Go
63 lines
1.7 KiB
Go
package database
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/glebarez/sqlite"
|
|
"gorm.io/gorm"
|
|
|
|
"github.com/truewhile/MeBox/internal/model"
|
|
)
|
|
|
|
func TestEnsureEmbyMountsCompatibility(t *testing.T) {
|
|
db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Create a table without sort_order simulating an older schema
|
|
if err := db.Exec(`CREATE TABLE emby_mounts (
|
|
id varchar(36) PRIMARY KEY,
|
|
created_at datetime,
|
|
updated_at datetime,
|
|
deleted_at datetime,
|
|
account_id text,
|
|
remote_view_id text,
|
|
remote_view_name text,
|
|
collection_type text,
|
|
name text,
|
|
proxy_play numeric DEFAULT false,
|
|
enabled numeric DEFAULT true
|
|
)`).Error; err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Insert older rows
|
|
now := time.Now()
|
|
_ = db.Exec("INSERT INTO emby_mounts (id, name, created_at) VALUES (?, ?, ?)", "m1", "Mount 1", now.Add(-2*time.Hour)).Error
|
|
_ = db.Exec("INSERT INTO emby_mounts (id, name, created_at) VALUES (?, ?, ?)", "m2", "Mount 2", now.Add(-1*time.Hour)).Error
|
|
|
|
// Run compatibility migration
|
|
if err := ensureEmbyMountsCompatibility(db); err != nil {
|
|
t.Fatalf("ensureEmbyMountsCompatibility failed: %v", err)
|
|
}
|
|
|
|
// Verify column sort_order exists and values are initialized sequentially
|
|
if !db.Migrator().HasColumn(&model.EmbyMount{}, "sort_order") {
|
|
t.Fatal("expected sort_order column to be added")
|
|
}
|
|
|
|
var m1, m2 model.EmbyMount
|
|
if err := db.Where("id = ?", "m1").First(&m1).Error; err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := db.Where("id = ?", "m2").First(&m2).Error; err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if m1.SortOrder != 0 || m2.SortOrder != 1 {
|
|
t.Fatalf("unexpected sort orders: m1=%d, m2=%d", m1.SortOrder, m2.SortOrder)
|
|
}
|
|
}
|