22 lines
470 B
Go
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{})
|
|
}
|