MCPcopy
hub / github.com/googleapis/mcp-toolbox / TestUpdateServer

Function TestUpdateServer

internal/server/server_test.go:218–305  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

216}
217
218func TestUpdateServer(t *testing.T) {
219 ctx, err := testutils.ContextWithNewLogger()
220 if err != nil {
221 t.Fatalf("error setting up logger: %s", err)
222 }
223
224 addr, port := "127.0.0.1", 5000
225 cfg := server.ServerConfig{
226 Version: "0.0.0",
227 Address: addr,
228 Port: port,
229 }
230
231 instrumentation, err := telemetry.CreateTelemetryInstrumentation(cfg.Version)
232 if err != nil {
233 t.Fatalf("unexpected error: %s", err)
234 }
235
236 ctx = util.WithInstrumentation(ctx, instrumentation)
237
238 s, err := server.NewServer(ctx, cfg)
239 if err != nil {
240 t.Fatalf("error setting up server: %s", err)
241 }
242
243 newSources := map[string]sources.Source{
244 "example-source": &alloydbpg.Source{
245 Config: alloydbpg.Config{
246 Name: "example-alloydb-source",
247 Type: "alloydb-postgres",
248 },
249 },
250 }
251 newAuth := map[string]auth.AuthService{"example-auth": nil}
252 newEmbeddingModels := map[string]embeddingmodels.EmbeddingModel{"example-model": nil}
253 newTools := map[string]tools.Tool{"example-tool": nil}
254 newToolsets := map[string]tools.Toolset{
255 "example-toolset": {
256 ToolsetConfig: tools.ToolsetConfig{
257 Name: "example-toolset",
258 },
259 Tools: []*tools.Tool{},
260 },
261 }
262 newPrompts := map[string]prompts.Prompt{"example-prompt": nil}
263 newPromptsets := map[string]prompts.Promptset{
264 "example-promptset": {
265 PromptsetConfig: prompts.PromptsetConfig{
266 Name: "example-promptset",
267 },
268 Prompts: []*prompts.Prompt{},
269 },
270 }
271 s.ResourceMgr.SetResources(newSources, newAuth, newEmbeddingModels, newTools, newToolsets, newPrompts, newPromptsets)
272 if err != nil {
273 t.Errorf("error updating server: %s", err)
274 }
275

Callers

nothing calls this directly

Calls 11

ContextWithNewLoggerFunction · 0.92
WithInstrumentationFunction · 0.92
NewServerFunction · 0.92
SetResourcesMethod · 0.80
GetAuthServiceMethod · 0.80
GetToolMethod · 0.80
GetToolsetMethod · 0.80
GetPromptMethod · 0.80
GetPromptsetMethod · 0.80
GetSourceMethod · 0.65

Tested by

no test coverage detected