Files
kra-new/tmp/live_acceptance/database.go
T
2026-09-23 17:42:55 +08:00

22 lines
470 B
Go

package main
import (
"fmt"
"path/filepath"
"github.com/glebarez/sqlite"
"gorm.io/gorm"
)
func openFixtureDB() (*gorm.DB, error) {
path, err := filepath.Abs(filepath.Join(outputDir, "acceptance.db"))
if err != nil {
return nil, err
}
root, err := filepath.Abs(outputDir)
if err != nil || filepath.Dir(path) != root {
return nil, fmt.Errorf("database path is not inside the acceptance directory")
}
return gorm.Open(sqlite.Open(path), &gorm.Config{})
}