fix: use in-memory SQLite and log temp directory cleanup in test:e2e

Switch from file-based SQLite to VIKUNJA_DATABASE_PATH=memory which uses
file::memory:?cache=shared. Also add a visible log line when cleaning up
the temp directory so the teardown sequence is clear.
This commit is contained in:
kolaente 2026-02-21 22:08:50 +01:00
parent 8f6f8f9e21
commit fec1c038ff
1 changed files with 7 additions and 3 deletions

View File

@ -476,18 +476,22 @@ func (Test) E2E(args string) error {
} }
} }
// Create temp directory for the SQLite DB and file uploads // Create temp directory for file uploads and rootpath
tmpDir, err := os.MkdirTemp("", "vikunja-e2e-*") tmpDir, err := os.MkdirTemp("", "vikunja-e2e-*")
if err != nil { if err != nil {
return fmt.Errorf("failed to create temp dir: %w", err) return fmt.Errorf("failed to create temp dir: %w", err)
} }
defer os.RemoveAll(tmpDir) defer func() {
fmt.Println("\n--- Cleaning up temp directory ---")
os.RemoveAll(tmpDir)
}()
if err := os.MkdirAll(filepath.Join(tmpDir, "files"), 0o755); err != nil { if err := os.MkdirAll(filepath.Join(tmpDir, "files"), 0o755); err != nil {
return fmt.Errorf("failed to create files dir: %w", err) return fmt.Errorf("failed to create files dir: %w", err)
} }
// Start the API server — all config via env vars, no config file // Start the API server — all config via env vars, no config file
// Uses in-memory SQLite (no DB file on disk)
fmt.Println("\n--- Starting API server ---") fmt.Println("\n--- Starting API server ---")
apiCmd := exec.Command("./vikunja", "web") apiCmd := exec.Command("./vikunja", "web")
apiCmd.Env = append(os.Environ(), apiCmd.Env = append(os.Environ(),
@ -497,7 +501,7 @@ func (Test) E2E(args string) error {
fmt.Sprintf("VIKUNJA_SERVICE_ROOTPATH=%s", tmpDir), fmt.Sprintf("VIKUNJA_SERVICE_ROOTPATH=%s", tmpDir),
"VIKUNJA_SERVICE_JWTSECRET=e2e-test-jwt-secret-do-not-use-in-production", "VIKUNJA_SERVICE_JWTSECRET=e2e-test-jwt-secret-do-not-use-in-production",
"VIKUNJA_DATABASE_TYPE=sqlite", "VIKUNJA_DATABASE_TYPE=sqlite",
fmt.Sprintf("VIKUNJA_DATABASE_PATH=%s", filepath.Join(tmpDir, "vikunja-e2e.db")), "VIKUNJA_DATABASE_PATH=memory",
fmt.Sprintf("VIKUNJA_FILES_BASEPATH=%s", filepath.Join(tmpDir, "files")), fmt.Sprintf("VIKUNJA_FILES_BASEPATH=%s", filepath.Join(tmpDir, "files")),
"VIKUNJA_LOG_LEVEL=WARNING", "VIKUNJA_LOG_LEVEL=WARNING",
"VIKUNJA_MAILER_ENABLED=false", "VIKUNJA_MAILER_ENABLED=false",