mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-12-23 01:24:24 +00:00
Implement SQLite database persistence for instance management
This commit is contained in:
@@ -3,10 +3,12 @@ package manager_test
|
||||
import (
|
||||
"llamactl/pkg/backends"
|
||||
"llamactl/pkg/config"
|
||||
"llamactl/pkg/database"
|
||||
"llamactl/pkg/instance"
|
||||
"llamactl/pkg/manager"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestCreateInstance_FailsWithDuplicateName(t *testing.T) {
|
||||
@@ -49,10 +51,28 @@ func TestCreateInstance_FailsWhenMaxInstancesReached(t *testing.T) {
|
||||
MaxInstances: 1, // Very low limit for testing
|
||||
TimeoutCheckInterval: 5,
|
||||
},
|
||||
Database: config.DatabaseConfig{
|
||||
Path: ":memory:",
|
||||
MaxOpenConnections: 25,
|
||||
MaxIdleConnections: 5,
|
||||
ConnMaxLifetime: 5 * time.Minute,
|
||||
},
|
||||
LocalNode: "main",
|
||||
Nodes: map[string]config.NodeConfig{},
|
||||
}
|
||||
limitedManager := manager.New(appConfig)
|
||||
db, err := database.Open(&database.Config{
|
||||
Path: appConfig.Database.Path,
|
||||
MaxOpenConnections: appConfig.Database.MaxOpenConnections,
|
||||
MaxIdleConnections: appConfig.Database.MaxIdleConnections,
|
||||
ConnMaxLifetime: appConfig.Database.ConnMaxLifetime,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to open database: %v", err)
|
||||
}
|
||||
if err := database.RunMigrations(db); err != nil {
|
||||
t.Fatalf("Failed to run migrations: %v", err)
|
||||
}
|
||||
limitedManager := manager.New(appConfig, db)
|
||||
|
||||
options := &instance.Options{
|
||||
BackendOptions: backends.Options{
|
||||
@@ -63,7 +83,7 @@ func TestCreateInstance_FailsWhenMaxInstancesReached(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
_, err := limitedManager.CreateInstance("instance1", options)
|
||||
_, err = limitedManager.CreateInstance("instance1", options)
|
||||
if err != nil {
|
||||
t.Fatalf("CreateInstance 1 failed: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user