generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: assign unassigned targets to gateways and preserve targets on removal #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aidandaly24
merged 4 commits into
aws:feat/gateway-integration
from
aidandaly24:feat/batch-3-assign-unassigned-targets
Feb 24, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6d7a427
feat: assign unassigned targets to gateways and preserve targets on r…
aidandaly24 b754374
test: add unit tests for unassigned target assignment and gateway rem…
aidandaly24 1f68c06
style: fix formatting and merge duplicate imports
aidandaly24 550ee75
docs: add comment explaining unassigned targets preservation
aidandaly24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/cli/operations/remove/__tests__/remove-gateway.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { previewRemoveGateway, removeGateway } from '../remove-gateway.js'; | ||
| import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| const { mockReadMcpSpec, mockWriteMcpSpec, mockConfigExists } = vi.hoisted(() => ({ | ||
| mockReadMcpSpec: vi.fn(), | ||
| mockWriteMcpSpec: vi.fn(), | ||
| mockConfigExists: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock('../../../../lib/index.js', () => ({ | ||
| ConfigIO: class { | ||
| configExists = mockConfigExists; | ||
| readMcpSpec = mockReadMcpSpec; | ||
| writeMcpSpec = mockWriteMcpSpec; | ||
| }, | ||
| })); | ||
|
|
||
| describe('removeGateway', () => { | ||
| afterEach(() => vi.clearAllMocks()); | ||
|
|
||
| it('moves gateway targets to unassignedTargets on removal, preserving existing', async () => { | ||
| mockReadMcpSpec.mockResolvedValue({ | ||
| agentCoreGateways: [ | ||
| { name: 'gw-to-remove', targets: [{ name: 'target-1' }, { name: 'target-2' }] }, | ||
| { name: 'other-gw', targets: [] }, | ||
| ], | ||
| unassignedTargets: [{ name: 'already-unassigned' }], | ||
| }); | ||
|
|
||
| const result = await removeGateway('gw-to-remove'); | ||
|
|
||
| expect(result.ok).toBe(true); | ||
| const written = mockWriteMcpSpec.mock.calls[0]![0]; | ||
| expect(written.agentCoreGateways).toHaveLength(1); | ||
| expect(written.agentCoreGateways[0]!.name).toBe('other-gw'); | ||
| expect(written.unassignedTargets).toHaveLength(3); | ||
| expect(written.unassignedTargets[0]!.name).toBe('already-unassigned'); | ||
| expect(written.unassignedTargets[1]!.name).toBe('target-1'); | ||
| expect(written.unassignedTargets[2]!.name).toBe('target-2'); | ||
| }); | ||
|
|
||
| it('does not modify unassignedTargets when gateway has no targets', async () => { | ||
| mockReadMcpSpec.mockResolvedValue({ | ||
| agentCoreGateways: [{ name: 'empty-gw', targets: [] }], | ||
| }); | ||
|
|
||
| const result = await removeGateway('empty-gw'); | ||
|
|
||
| expect(result.ok).toBe(true); | ||
| const written = mockWriteMcpSpec.mock.calls[0]![0]; | ||
| expect(written.agentCoreGateways).toHaveLength(0); | ||
| expect(written.unassignedTargets).toBeUndefined(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('previewRemoveGateway', () => { | ||
| afterEach(() => vi.clearAllMocks()); | ||
|
|
||
| it('shows "will become unassigned" warning when gateway has targets', async () => { | ||
| mockReadMcpSpec.mockResolvedValue({ | ||
| agentCoreGateways: [{ name: 'my-gw', targets: [{ name: 't1' }, { name: 't2' }] }], | ||
| }); | ||
|
|
||
| const preview = await previewRemoveGateway('my-gw'); | ||
|
|
||
| expect(preview.summary.some(s => s.includes('2 target(s) will become unassigned'))).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.