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:
@@ -512,13 +512,19 @@ func detectDatabases(beadsDir string) ([]*dbInfo, error) {
|
||||
}
|
||||
|
||||
func getDBVersion(dbPath string) string {
|
||||
// Open database read-only
|
||||
db, err := sql.Open("sqlite", dbPath+"?mode=ro")
|
||||
// Open database read-only using file URI (same as production code)
|
||||
connStr := "file:" + dbPath + "?mode=ro&_time_format=sqlite"
|
||||
db, err := sql.Open("sqlite3", connStr)
|
||||
if err != nil {
|
||||
return "unknown"
|
||||
}
|
||||
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
|
||||
var version string
|
||||
err = db.QueryRow("SELECT value FROM metadata WHERE key = 'bd_version'").Scan(&version)
|
||||
@@ -526,6 +532,7 @@ func getDBVersion(dbPath string) string {
|
||||
return version
|
||||
}
|
||||
|
||||
// If the row doesn't exist but table does, this is still a database with metadata
|
||||
// Check if metadata table exists
|
||||
var tableName string
|
||||
err = db.QueryRow(`
|
||||
@@ -537,6 +544,11 @@ func getDBVersion(dbPath string) string {
|
||||
return "pre-0.17.5"
|
||||
}
|
||||
|
||||
// Table exists but version query failed (probably no bd_version key)
|
||||
if err == nil {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user