Feat v0.8.2 capability negotiation #69
@@ -158,9 +158,9 @@ func TestBundledInstall_EmptyDir(t *testing.T) {
|
||||
InstallBundledPackages(bundledDir, "", "", stores, nil, nil)
|
||||
}
|
||||
|
||||
// TestBundledInstall_DormantPackage verifies that bundled packages with
|
||||
// unmet requires are marked dormant.
|
||||
func TestBundledInstall_DormantPackage(t *testing.T) {
|
||||
// TestBundledInstall_SkippedOnUnmetRequiredCaps verifies that bundled
|
||||
// packages with unmet capabilities.required are skipped (not registered).
|
||||
func TestBundledInstall_SkippedOnUnmetRequiredCaps(t *testing.T) {
|
||||
stores := newTestStores(t)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -168,24 +168,21 @@ func TestBundledInstall_DormantPackage(t *testing.T) {
|
||||
packagesDir := t.TempDir()
|
||||
|
||||
buildTestPkg(t, bundledDir, map[string]any{
|
||||
"id": "dormant-pkg",
|
||||
"title": "Dormant Package",
|
||||
"type": "extension",
|
||||
"hooks": []string{"on_install"},
|
||||
"requires": []string{"chat"},
|
||||
"id": "needs-pgvector",
|
||||
"title": "Needs pgvector",
|
||||
"type": "extension",
|
||||
"hooks": []string{"on_install"},
|
||||
"capabilities": map[string]any{
|
||||
"required": []string{"pgvector"},
|
||||
},
|
||||
})
|
||||
|
||||
// No capabilities detected → pgvector is unavailable
|
||||
InstallBundledPackages(bundledDir, packagesDir, "*", stores, nil, nil)
|
||||
|
||||
pkg, err := stores.Packages.Get(ctx, "dormant-pkg")
|
||||
if err != nil || pkg == nil {
|
||||
t.Fatal("dormant package not found after install")
|
||||
}
|
||||
if pkg.Status != "dormant" {
|
||||
t.Errorf("status = %q, want %q", pkg.Status, "dormant")
|
||||
}
|
||||
if pkg.Enabled {
|
||||
t.Error("dormant package should not be enabled")
|
||||
pkg, _ := stores.Packages.Get(ctx, "needs-pgvector")
|
||||
if pkg != nil {
|
||||
t.Error("package with unmet required capabilities should not be registered")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -438,7 +438,7 @@ func TestUpgrade_BundledSkipExistingOnRestart(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpgrade_PackageDormantOnUnmetRequires(t *testing.T) {
|
||||
func TestUpgrade_PackageSkippedOnUnmetRequiredCaps(t *testing.T) {
|
||||
stores := newTestStores(t)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -447,25 +447,22 @@ func TestUpgrade_PackageDormantOnUnmetRequires(t *testing.T) {
|
||||
|
||||
// Package requires a capability that doesn't exist
|
||||
buildTestPkg(t, bundledDir, map[string]any{
|
||||
"id": "future-pkg",
|
||||
"title": "Future",
|
||||
"type": "extension",
|
||||
"version": "1.0.0",
|
||||
"hooks": []string{"on_install"},
|
||||
"requires": []string{"kernel>=99.0.0"},
|
||||
"id": "future-pkg",
|
||||
"title": "Future",
|
||||
"type": "extension",
|
||||
"version": "1.0.0",
|
||||
"hooks": []string{"on_install"},
|
||||
"capabilities": map[string]any{
|
||||
"required": []string{"pgvector"},
|
||||
},
|
||||
})
|
||||
|
||||
// No capabilities detected → pgvector is unavailable
|
||||
InstallBundledPackages(bundledDir, packagesDir, "*", stores, nil, nil)
|
||||
|
||||
pkg, _ := stores.Packages.Get(ctx, "future-pkg")
|
||||
if pkg == nil {
|
||||
t.Fatal("package should still be registered")
|
||||
}
|
||||
if pkg.Status != "dormant" {
|
||||
t.Errorf("status = %q, want %q", pkg.Status, "dormant")
|
||||
}
|
||||
if pkg.Enabled {
|
||||
t.Error("dormant package should not be enabled")
|
||||
if pkg != nil {
|
||||
t.Error("package with unmet required capabilities should not be registered")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user