(t *testing.T)
| 671 | } |
| 672 | |
| 673 | func TestAwInfoHasMCPServers(t *testing.T) { |
| 674 | tests := []struct { |
| 675 | name string |
| 676 | awInfoContent string |
| 677 | awInfoSubdir string |
| 678 | expectedNames []string |
| 679 | expectedHasMCP bool |
| 680 | }{ |
| 681 | { |
| 682 | name: "with MCP servers", |
| 683 | awInfoContent: `{"engine_id":"copilot","steps":{"mcp_servers":{"github":{},"filesystem":{}}}}`, |
| 684 | expectedNames: []string{"filesystem", "github"}, |
| 685 | expectedHasMCP: true, |
| 686 | }, |
| 687 | { |
| 688 | name: "without MCP servers", |
| 689 | awInfoContent: `{"engine_id":"copilot","steps":{"firewall":"squid"}}`, |
| 690 | expectedHasMCP: false, |
| 691 | }, |
| 692 | { |
| 693 | name: "without steps", |
| 694 | awInfoContent: `{"engine_id":"copilot"}`, |
| 695 | expectedHasMCP: false, |
| 696 | }, |
| 697 | { |
| 698 | name: "with MCP servers in activation subdir", |
| 699 | awInfoContent: `{"engine_id":"copilot","steps":{"mcp_servers":{"github":{}}}}`, |
| 700 | awInfoSubdir: "activation", |
| 701 | expectedNames: []string{"github"}, |
| 702 | expectedHasMCP: true, |
| 703 | }, |
| 704 | } |
| 705 | |
| 706 | for _, tt := range tests { |
| 707 | t.Run(tt.name, func(t *testing.T) { |
| 708 | tmpDir := testutil.TempDir(t, "mcp-servers-*") |
| 709 | targetDir := tmpDir |
| 710 | if tt.awInfoSubdir != "" { |
| 711 | targetDir = filepath.Join(tmpDir, tt.awInfoSubdir) |
| 712 | err := os.MkdirAll(targetDir, 0755) |
| 713 | require.NoError(t, err, "Should create subdir") |
| 714 | } |
| 715 | err := os.WriteFile(filepath.Join(targetDir, "aw_info.json"), []byte(tt.awInfoContent), 0644) |
| 716 | require.NoError(t, err, "Should write aw_info.json") |
| 717 | |
| 718 | names, hasMCP := extractMCPServerNamesFromAwInfo(tmpDir) |
| 719 | assert.Equal(t, tt.expectedHasMCP, hasMCP, "Has MCP servers should match") |
| 720 | if tt.expectedHasMCP { |
| 721 | assert.Equal(t, tt.expectedNames, names, "MCP server names should match") |
| 722 | } |
| 723 | }) |
| 724 | } |
| 725 | } |
nothing calls this directly
no test coverage detected