fix: resolve CI test failures on Linux and Windows
- Fix TestMigrateCommand: Use correct sqlite3 driver name and file URI format - Fix TestDaemonAutoImportAfterGitPull: Add Windows-specific delay for filesystem timestamp precision - Fix TestSyncBranchPull_Success: Add Windows-specific delay for file I/O settling Amp-Thread-ID: https://ampcode.com/threads/T-5abd1f2f-9607-4111-af9d-19df64362ac7 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -132,7 +133,13 @@ func TestDaemonAutoImportAfterGitPull(t *testing.T) {
|
|||||||
runGitCmd(t, clone2Dir, "pull")
|
runGitCmd(t, clone2Dir, "pull")
|
||||||
|
|
||||||
// Wait for filesystem to settle after git operations
|
// Wait for filesystem to settle after git operations
|
||||||
time.Sleep(50 * time.Millisecond)
|
// Windows has lower filesystem timestamp precision (typically 100ms)
|
||||||
|
// so we need a longer delay to ensure mtime comparison works
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
} else {
|
||||||
|
time.Sleep(50 * time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
// Start daemon server in clone2
|
// Start daemon server in clone2
|
||||||
socketPath := filepath.Join(clone2BeadsDir, "bd.sock")
|
socketPath := filepath.Join(clone2BeadsDir, "bd.sock")
|
||||||
|
|||||||
@@ -563,6 +563,11 @@ func TestSyncBranchPull_Success(t *testing.T) {
|
|||||||
t.Error("JSONL not copied to main repo after pull")
|
t.Error("JSONL not copied to main repo after pull")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On Windows, file I/O may need time to settle
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
// Verify JSONL content matches
|
// Verify JSONL content matches
|
||||||
clone1Data, err := os.ReadFile(clone1JSONLPath)
|
clone1Data, err := os.ReadFile(clone1JSONLPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -512,13 +512,19 @@ func detectDatabases(beadsDir string) ([]*dbInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getDBVersion(dbPath string) string {
|
func getDBVersion(dbPath string) string {
|
||||||
// Open database read-only
|
// Open database read-only using file URI (same as production code)
|
||||||
db, err := sql.Open("sqlite", dbPath+"?mode=ro")
|
connStr := "file:" + dbPath + "?mode=ro&_time_format=sqlite"
|
||||||
|
db, err := sql.Open("sqlite3", connStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
|
// Ping to ensure connection is actually established
|
||||||
|
if err := db.Ping(); err != nil {
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
|
||||||
// Try to read version from metadata table
|
// Try to read version from metadata table
|
||||||
var version string
|
var version string
|
||||||
err = db.QueryRow("SELECT value FROM metadata WHERE key = 'bd_version'").Scan(&version)
|
err = db.QueryRow("SELECT value FROM metadata WHERE key = 'bd_version'").Scan(&version)
|
||||||
@@ -526,6 +532,7 @@ func getDBVersion(dbPath string) string {
|
|||||||
return version
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the row doesn't exist but table does, this is still a database with metadata
|
||||||
// Check if metadata table exists
|
// Check if metadata table exists
|
||||||
var tableName string
|
var tableName string
|
||||||
err = db.QueryRow(`
|
err = db.QueryRow(`
|
||||||
@@ -537,6 +544,11 @@ func getDBVersion(dbPath string) string {
|
|||||||
return "pre-0.17.5"
|
return "pre-0.17.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Table exists but version query failed (probably no bd_version key)
|
||||||
|
if err == nil {
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user