osaet/backend/internal/admin/migrations_test.go
yarnom f0b50d13ea feat: add admin publishing workflow and yar theme
Add Go/Postgres admin APIs, Angular admin UI, manual build flow, asset uploads, markdown import/export, configurable slug generation, and the Yar reading theme. Exclude local docs and generated development artifacts from version control.
2026-06-01 15:48:04 +08:00

35 lines
916 B
Go

package admin
import (
"os"
"path/filepath"
"testing"
)
func TestLoadMigrationFiles(t *testing.T) {
dir := t.TempDir()
files := map[string]string{
"002_second.sql": "select 2;",
"001_first.sql": "select 1;",
"notes.txt": "ignored",
}
for name, content := range files {
if err := os.WriteFile(filepath.Join(dir, name), []byte(content), 0o600); err != nil {
t.Fatalf("write fixture: %v", err)
}
}
migrations, err := LoadMigrationFiles(dir)
if err != nil {
t.Fatalf("load migrations: %v", err)
}
if len(migrations) != 2 {
t.Fatalf("expected 2 migrations, got %d", len(migrations))
}
if migrations[0].Version != "001_first.sql" || migrations[1].Version != "002_second.sql" {
t.Fatalf("unexpected migration order: %#v", migrations)
}
if migrations[0].Checksum == "" || migrations[0].Checksum == migrations[1].Checksum {
t.Fatalf("unexpected checksums: %#v", migrations)
}
}