test(plugin): check type assertions to satisfy errcheck lint

This commit is contained in:
shaw committed 2026-09-19 11:47:14 +08:00
1 parent c63bd14a02
commit 6477143533
2 files changed
+6 -3

No files matched your search

@@ -15,7 +15,8 @@ func newTestPluginKVStore(t *testing.T) (*pluginKVStore, *miniredis.Miniredis) {
t.Helper() t.Helper()
mr := miniredis.RunT(t) mr := miniredis.RunT(t)
rdb := redis.NewClient(&redis.Options{Addr: mr.Addr()}) rdb := redis.NewClient(&redis.Options{Addr: mr.Addr()})
store := NewPluginKVStore(rdb).(*pluginKVStore) store, ok := NewPluginKVStore(rdb).(*pluginKVStore)
require.True(t, ok)
return store, mr return store, mr
} }
@@ -317,13 +317,15 @@ func TestBuildHostServicesGatesDirectoryByCapability(t *testing.T) {
authorized := &PluginInstallation{PluginKey: "p.authorized", Manifest: PluginManifest{ authorized := &PluginInstallation{PluginKey: "p.authorized", Manifest: PluginManifest{
Capabilities: []PluginCapability{{ID: PluginCapabilityOpenAIOAuthOutbound, Platform: PlatformOpenAI, AccountType: AccountTypeOAuth}}, Capabilities: []PluginCapability{{ID: PluginCapabilityOpenAIOAuthOutbound, Platform: PlatformOpenAI, AccountType: AccountTypeOAuth}},
}} }}
srv := m.buildHostServices(authorized).(*pluginHostServiceServer) srv, ok := m.buildHostServices(authorized).(*pluginHostServiceServer)
require.True(t, ok)
require.NotNil(t, srv.directory) require.NotNil(t, srv.directory)
unauthorized := &PluginInstallation{PluginKey: "p.other", Manifest: PluginManifest{ unauthorized := &PluginInstallation{PluginKey: "p.other", Manifest: PluginManifest{
Capabilities: []PluginCapability{{ID: "some.other.capability", Platform: "x", AccountType: "y"}}, Capabilities: []PluginCapability{{ID: "some.other.capability", Platform: "x", AccountType: "y"}},
}} }}
srv2 := m.buildHostServices(unauthorized).(*pluginHostServiceServer) srv2, ok := m.buildHostServices(unauthorized).(*pluginHostServiceServer)
require.True(t, ok)
require.Nil(t, srv2.directory, "unauthorized plugin must not receive the account directory") require.Nil(t, srv2.directory, "unauthorized plugin must not receive the account directory")
require.NotNil(t, srv2.store, "but KV remains available") require.NotNil(t, srv2.store, "but KV remains available")
} }