MCPcopy Index your code
hub / github.com/coder/coder / TestMCPServerConfigsAvailability

Function TestMCPServerConfigsAvailability

coderd/mcp_test.go:433–480  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

431}
432
433func TestMCPServerConfigsAvailability(t *testing.T) {
434 t.Parallel()
435
436 client := newMCPClient(t)
437 _ = coderdtest.CreateFirstUser(t, client)
438
439 validValues := []string{"force_on", "default_on", "default_off"}
440 for _, av := range validValues {
441 av := av
442 t.Run(av, func(t *testing.T) {
443 t.Parallel()
444 ctx := testutil.Context(t, testutil.WaitLong)
445 created, err := client.CreateMCPServerConfig(ctx, codersdk.CreateMCPServerConfigRequest{
446 DisplayName: "Server " + av,
447 Slug: "server-" + av,
448 Transport: "streamable_http",
449 URL: "https://mcp.example.com/" + av,
450 AuthType: "none",
451 Availability: av,
452 Enabled: true,
453 ToolAllowList: []string{},
454 ToolDenyList: []string{},
455 })
456 require.NoError(t, err)
457 require.Equal(t, av, created.Availability)
458 })
459 }
460
461 t.Run("InvalidAvailability", func(t *testing.T) {
462 t.Parallel()
463 ctx := testutil.Context(t, testutil.WaitLong)
464 _, err := client.CreateMCPServerConfig(ctx, codersdk.CreateMCPServerConfigRequest{
465 DisplayName: "Bad Availability",
466 Slug: "bad-avail",
467 Transport: "streamable_http",
468 URL: "https://mcp.example.com/bad",
469 AuthType: "none",
470 Availability: "always_on",
471 Enabled: true,
472 ToolAllowList: []string{},
473 ToolDenyList: []string{},
474 })
475 require.Error(t, err)
476 var sdkErr *codersdk.Error
477 require.ErrorAs(t, err, &sdkErr)
478 require.Equal(t, http.StatusBadRequest, sdkErr.StatusCode())
479 })
480}
481
482func TestMCPServerConfigsUniqueSlug(t *testing.T) {
483 t.Parallel()

Callers

nothing calls this directly

Calls 8

StatusCodeMethod · 0.95
CreateFirstUserFunction · 0.92
ContextFunction · 0.92
newMCPClientFunction · 0.85
CreateMCPServerConfigMethod · 0.80
RunMethod · 0.65
EqualMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected