mirror of
https://github.com/navidrome/navidrome.git
synced 2025-08-10 00:52:20 +00:00
Some checks failed
Pipeline: Test, Lint, Build / Get version info (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test JS code (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint i18n files (push) Has been cancelled
Pipeline: Test, Lint, Build / Check Docker configuration (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v5) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v6) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v7) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Push Docker manifest (push) Has been cancelled
Pipeline: Test, Lint, Build / Build Windows installers (push) Has been cancelled
Pipeline: Test, Lint, Build / Package/Release (push) Has been cancelled
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Has been cancelled
* fix(server): import playlists with absolute paths Signed-off-by: Deluan <deluan@navidrome.org> * fix(server): optimize playlist import Signed-off-by: Deluan <deluan@navidrome.org> * fix(server): add test with multiple libraries Signed-off-by: Deluan <deluan@navidrome.org> * fix(server): refactor Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org>
38 lines
842 B
Go
38 lines
842 B
Go
package tests
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/navidrome/navidrome/db"
|
|
"github.com/navidrome/navidrome/model/id"
|
|
)
|
|
|
|
type testingT interface {
|
|
TempDir() string
|
|
}
|
|
|
|
func TempFileName(t testingT, prefix, suffix string) string {
|
|
return filepath.Join(t.TempDir(), prefix+id.NewRandom()+suffix)
|
|
}
|
|
|
|
func TempFile(t testingT, prefix, suffix string) (*os.File, string, error) {
|
|
name := TempFileName(t, prefix, suffix)
|
|
f, err := os.Create(name)
|
|
return f, name, err
|
|
}
|
|
|
|
// ClearDB deletes all tables and data from the database
|
|
// https://stackoverflow.com/questions/525512/drop-all-tables-command
|
|
func ClearDB() error {
|
|
_, err := db.Db().ExecContext(context.Background(), `
|
|
PRAGMA writable_schema = 1;
|
|
DELETE FROM sqlite_master;
|
|
PRAGMA writable_schema = 0;
|
|
VACUUM;
|
|
PRAGMA integrity_check;
|
|
`)
|
|
return err
|
|
}
|