对接
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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{})
|
||||
}
|
||||
Reference in New Issue
Block a user