One connector, registered once per brand with the brand fixed, so the
panel, the Web App and the Phone App each list Toyota, Lexus and Subaru
separately: own card, own account, own enable switch, own
/api/integrations/{brand} routes and vehicle provider. The brand picker
is gone.
Settings saved before the split under pluginSettings.toyota with brand
L or S move onto their brand's key on read, and are written back on the
next save. Cars linked as provider "toyota" read through their make's
brand.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
package builtin
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"drivervault/apiserver/internal/plugins"
|
|
)
|
|
|
|
// The blank imports above are the whole content of this package, and forgetting
|
|
// one is a silent failure: the connector compiles, its tests pass, and it simply
|
|
// never appears in the panel. This pins the list.
|
|
func TestEveryBuiltinIsRegistered(t *testing.T) {
|
|
// List needs no store: it reports the registered factories, and the records
|
|
// it would merge in come from a Manager that has loaded.
|
|
views := plugins.NewManager(nil).List()
|
|
|
|
seen := map[string]plugins.View{}
|
|
for _, v := range views {
|
|
seen[v.Name] = v
|
|
}
|
|
|
|
want := map[string]string{
|
|
"anker-solix": plugins.CategoryChargers,
|
|
"apprise": plugins.CategoryNotifications,
|
|
"greencell": plugins.CategoryChargers,
|
|
"toyota": plugins.CategoryVehicles,
|
|
// One connector, three registrations: see toyota.Brands.
|
|
"lexus": plugins.CategoryVehicles,
|
|
"subaru": plugins.CategoryVehicles,
|
|
}
|
|
for name, category := range want {
|
|
v, ok := seen[name]
|
|
if !ok {
|
|
t.Errorf("%q is not registered — is it blank-imported in builtin.go?", name)
|
|
continue
|
|
}
|
|
if v.Kind != plugins.KindBuiltin {
|
|
t.Errorf("%q kind = %q, want builtin", name, v.Kind)
|
|
}
|
|
if v.Category != category {
|
|
t.Errorf("%q category = %q, want %q", name, v.Category, category)
|
|
}
|
|
if v.Provider == "" || v.Version == "" {
|
|
t.Errorf("%q should name a provider and a version, got %q / %q", name, v.Provider, v.Version)
|
|
}
|
|
if len(v.Capabilities) == 0 {
|
|
t.Errorf("%q advertises no capabilities", name)
|
|
}
|
|
}
|
|
if len(seen) != len(want) {
|
|
t.Errorf("registered builtins = %d, expected %d — update this test with the new connector", len(seen), len(want))
|
|
}
|
|
}
|