mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-20 14:00:04 +02:00
Move fixture generation to contrib and add test (#10277)
* Add fixture gen tool and fix "access" test * Close file before exiting * Add missing repo_unit for repo id: 5 * Fix count on TestAPIOrgRepos * Generate access fixture from contrib and add test * Remove old access fixture generation * Fix lint Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
62a1322cf9
commit
7e920703f9
5 changed files with 163 additions and 56 deletions
|
@ -28,7 +28,10 @@ import (
|
|||
const NonexistentID = int64(math.MaxInt64)
|
||||
|
||||
// giteaRoot a path to the gitea root
|
||||
var giteaRoot string
|
||||
var (
|
||||
giteaRoot string
|
||||
fixturesDir string
|
||||
)
|
||||
|
||||
func fatalTestError(fmtStr string, args ...interface{}) {
|
||||
fmt.Fprintf(os.Stderr, fmtStr, args...)
|
||||
|
@ -40,8 +43,8 @@ func fatalTestError(fmtStr string, args ...interface{}) {
|
|||
func MainTest(m *testing.M, pathToGiteaRoot string) {
|
||||
var err error
|
||||
giteaRoot = pathToGiteaRoot
|
||||
fixturesDir := filepath.Join(pathToGiteaRoot, "models", "fixtures")
|
||||
if err = createTestEngine(fixturesDir); err != nil {
|
||||
fixturesDir = filepath.Join(pathToGiteaRoot, "models", "fixtures")
|
||||
if err = CreateTestEngine(fixturesDir); err != nil {
|
||||
fatalTestError("Error creating test engine: %v\n", err)
|
||||
}
|
||||
|
||||
|
@ -82,7 +85,8 @@ func MainTest(m *testing.M, pathToGiteaRoot string) {
|
|||
os.Exit(exitStatus)
|
||||
}
|
||||
|
||||
func createTestEngine(fixturesDir string) error {
|
||||
// CreateTestEngine creates a memory database and loads the fixture data from fixturesDir
|
||||
func CreateTestEngine(fixturesDir string) error {
|
||||
var err error
|
||||
x, err = xorm.NewEngine("sqlite3", "file::memory:?cache=shared")
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue