The tree adds the installer, service and test paths admitted by this source commit. Nothing else changes about what may cross. Source-Sha: 3e4a3aa4ce092e9e3f51bc78daf3ddc14d9638f8 Policy-Sha: 3e4a3aa4ce092e9e3f51bc78daf3ddc14d9638f8 Tree-Digest: 89d6fce3828a0e0de0c8eeb41ee6750f4462217e2a04b5190297134d7f4a50c3
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package database
|
|
|
|
import (
|
|
"bytes"
|
|
"io/fs"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestNativeMigrationPayloadMatchesSource(t *testing.T) {
|
|
sources, err := filepath.Glob("migrations/*.up.sql")
|
|
if err != nil || len(sources) == 0 {
|
|
t.Fatalf("migration source inventory: %v (%d files)", err, len(sources))
|
|
}
|
|
embedded, err := fs.Glob(embeddedMigrations, "migrations/*.up.sql")
|
|
if err != nil || len(embedded) != len(sources) {
|
|
t.Fatalf("embedded inventory: %v (%d files, want %d)", err, len(embedded), len(sources))
|
|
}
|
|
for _, name := range sources {
|
|
want, err := os.ReadFile(name)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got, err := embeddedMigrations.ReadFile(filepath.ToSlash(name))
|
|
if err != nil || !bytes.Equal(got, want) {
|
|
t.Fatalf("embedded migration differs: %s: %v", name, err)
|
|
}
|
|
}
|
|
// Service startup may run from System32, not the checkout or install dir.
|
|
t.Chdir(t.TempDir())
|
|
for _, name := range embedded {
|
|
if _, err := embeddedMigrations.ReadFile(name); err != nil {
|
|
t.Fatalf("migration depends on working directory: %s: %v", name, err)
|
|
}
|
|
}
|
|
}
|