(t *testing.T)
| 236 | } |
| 237 | |
| 238 | func TestConnectAll_DeterministicOrder(t *testing.T) { |
| 239 | t.Parallel() |
| 240 | |
| 241 | t.Run("AcrossServers", func(t *testing.T) { |
| 242 | t.Parallel() |
| 243 | ctx := context.Background() |
| 244 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}) |
| 245 | |
| 246 | ts1 := newTestMCPServer(t, makeTool("zebra")) |
| 247 | ts2 := newTestMCPServer(t, makeTool("alpha")) |
| 248 | ts3 := newTestMCPServer(t, makeTool("middle")) |
| 249 | |
| 250 | tools, cleanup := mcpclient.ConnectAll( |
| 251 | ctx, |
| 252 | logger, |
| 253 | []database.MCPServerConfig{ |
| 254 | makeConfig("srv3", ts3.URL), |
| 255 | makeConfig("srv1", ts1.URL), |
| 256 | makeConfig("srv2", ts2.URL), |
| 257 | }, |
| 258 | nil, |
| 259 | uuid.Nil, nil, |
| 260 | nil, |
| 261 | ) |
| 262 | t.Cleanup(cleanup) |
| 263 | |
| 264 | require.Len(t, tools, 3) |
| 265 | // Sorted by full prefixed name (slug__tool), so slug |
| 266 | // order determines the sequence, not the tool name. |
| 267 | assert.Equal(t, |
| 268 | []string{"srv1__zebra", "srv2__alpha", "srv3__middle"}, |
| 269 | toolNames(tools), |
| 270 | ) |
| 271 | }) |
| 272 | |
| 273 | t.Run("WithMultiToolServer", func(t *testing.T) { |
| 274 | t.Parallel() |
| 275 | ctx := context.Background() |
| 276 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}) |
| 277 | |
| 278 | multi := newTestMCPServer(t, makeTool("zeta"), makeTool("beta")) |
| 279 | other := newTestMCPServer(t, makeTool("gamma")) |
| 280 | |
| 281 | tools, cleanup := mcpclient.ConnectAll( |
| 282 | ctx, |
| 283 | logger, |
| 284 | []database.MCPServerConfig{ |
| 285 | makeConfig("zzz", multi.URL), |
| 286 | makeConfig("aaa", other.URL), |
| 287 | }, |
| 288 | nil, |
| 289 | uuid.Nil, nil, |
| 290 | nil, |
| 291 | ) |
| 292 | t.Cleanup(cleanup) |
| 293 | |
| 294 | require.Len(t, tools, 3) |
| 295 | assert.Equal(t, |
nothing calls this directly
no test coverage detected