1010 */
1111import type { GatewayTargetDetail } from '../../../aws/agentcore-control' ;
1212import { toGatewayTargetSpec } from '../import-gateway' ;
13- import { describe , expect , it , vi } from 'vitest' ;
13+ import { assert , describe , expect , it , vi } from 'vitest' ;
1414
1515/** Helper to build a minimal GatewayTargetDetail with only the fields under test. */
1616function baseDetail ( overrides : Partial < GatewayTargetDetail > = { } ) : GatewayTargetDetail {
@@ -48,12 +48,12 @@ describe('toGatewayTargetSpec — apiGateway', () => {
4848 const onProgress = vi . fn ( ) ;
4949 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
5050
51- expect ( result ) . toBeDefined ( ) ;
52- expect ( result ! . name ) . toBe ( 'test_target' ) ;
53- expect ( result ! . targetType ) . toBe ( 'apiGateway' ) ;
51+ assert ( result . success ) ;
52+ expect ( result . target ! . name ) . toBe ( 'test_target' ) ;
53+ expect ( result . target ! . targetType ) . toBe ( 'apiGateway' ) ;
5454
5555 // eslint-disable-next-line @typescript-eslint/no-explicit-any
56- const apigw = ( result as any ) . apiGateway ;
56+ const apigw = ( result . target as any ) . apiGateway ;
5757 expect ( apigw . restApiId ) . toBe ( 'abc123' ) ;
5858 expect ( apigw . stage ) . toBe ( 'prod' ) ;
5959 expect ( apigw . apiGatewayToolConfiguration . toolFilters ) . toEqual ( [
@@ -84,8 +84,9 @@ describe('toGatewayTargetSpec — apiGateway', () => {
8484 const onProgress = vi . fn ( ) ;
8585 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
8686
87+ assert ( result . success ) ;
8788 // eslint-disable-next-line @typescript-eslint/no-explicit-any
88- const apigw = ( result as any ) . apiGateway ;
89+ const apigw = ( result . target as any ) . apiGateway ;
8990 expect ( apigw . apiGatewayToolConfiguration . toolOverrides ) . toEqual ( [
9091 { name : 'listPets' , path : '/pets' , method : 'GET' , description : 'List all pets' } ,
9192 { name : 'createPet' , path : '/pets' , method : 'POST' } ,
@@ -110,8 +111,9 @@ describe('toGatewayTargetSpec — apiGateway', () => {
110111 const onProgress = vi . fn ( ) ;
111112 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
112113
114+ assert ( result . success ) ;
113115 // eslint-disable-next-line @typescript-eslint/no-explicit-any
114- const apigw = ( result as any ) . apiGateway ;
116+ const apigw = ( result . target as any ) . apiGateway ;
115117 expect ( apigw . apiGatewayToolConfiguration . toolOverrides ) . toBeUndefined ( ) ;
116118 } ) ;
117119
@@ -144,8 +146,8 @@ describe('toGatewayTargetSpec — apiGateway', () => {
144146 const onProgress = vi . fn ( ) ;
145147 const result = toGatewayTargetSpec ( detail , credentials , onProgress ) ;
146148
147- expect ( result ) . toBeDefined ( ) ;
148- expect ( result ! . outboundAuth ) . toEqual ( {
149+ assert ( result . success ) ;
150+ expect ( result . target ! . outboundAuth ) . toEqual ( {
149151 type : 'OAUTH' ,
150152 credentialName : 'my_oauth_cred' ,
151153 scopes : [ 'read' , 'write' ] ,
@@ -172,12 +174,12 @@ describe('toGatewayTargetSpec — openApiSchema', () => {
172174 const onProgress = vi . fn ( ) ;
173175 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
174176
175- expect ( result ) . toBeDefined ( ) ;
176- expect ( result ! . name ) . toBe ( 'test_target' ) ;
177- expect ( result ! . targetType ) . toBe ( 'openApiSchema' ) ;
177+ assert ( result . success ) ;
178+ expect ( result . target ! . name ) . toBe ( 'test_target' ) ;
179+ expect ( result . target ! . targetType ) . toBe ( 'openApiSchema' ) ;
178180
179181 // eslint-disable-next-line @typescript-eslint/no-explicit-any
180- const schemaSource = ( result as any ) . schemaSource ;
182+ const schemaSource = ( result . target as any ) . schemaSource ;
181183 expect ( schemaSource . s3 . uri ) . toBe ( 's3://my-bucket/schema.yaml' ) ;
182184 expect ( schemaSource . s3 . bucketOwnerAccountId ) . toBe ( '123456789012' ) ;
183185 } ) ;
@@ -194,7 +196,8 @@ describe('toGatewayTargetSpec — openApiSchema', () => {
194196 const onProgress = vi . fn ( ) ;
195197 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
196198
197- expect ( result ) . toBeUndefined ( ) ;
199+ assert ( result . success ) ;
200+ expect ( result . target ) . toBeUndefined ( ) ;
198201 expect ( onProgress ) . toHaveBeenCalledWith ( expect . stringContaining ( '(openApiSchema) has no S3 URI, skipping' ) ) ;
199202 } ) ;
200203} ) ;
@@ -218,12 +221,12 @@ describe('toGatewayTargetSpec — smithyModel', () => {
218221 const onProgress = vi . fn ( ) ;
219222 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
220223
221- expect ( result ) . toBeDefined ( ) ;
222- expect ( result ! . name ) . toBe ( 'test_target' ) ;
223- expect ( result ! . targetType ) . toBe ( 'smithyModel' ) ;
224+ assert ( result . success ) ;
225+ expect ( result . target ! . name ) . toBe ( 'test_target' ) ;
226+ expect ( result . target ! . targetType ) . toBe ( 'smithyModel' ) ;
224227
225228 // eslint-disable-next-line @typescript-eslint/no-explicit-any
226- const schemaSource = ( result as any ) . schemaSource ;
229+ const schemaSource = ( result . target as any ) . schemaSource ;
227230 expect ( schemaSource . s3 . uri ) . toBe ( 's3://models-bucket/model.json' ) ;
228231 expect ( schemaSource . s3 . bucketOwnerAccountId ) . toBeUndefined ( ) ;
229232 } ) ;
@@ -240,7 +243,8 @@ describe('toGatewayTargetSpec — smithyModel', () => {
240243 const onProgress = vi . fn ( ) ;
241244 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
242245
243- expect ( result ) . toBeUndefined ( ) ;
246+ assert ( result . success ) ;
247+ expect ( result . target ) . toBeUndefined ( ) ;
244248 expect ( onProgress ) . toHaveBeenCalledWith ( expect . stringContaining ( '(smithyModel) has no S3 URI, skipping' ) ) ;
245249 } ) ;
246250} ) ;
@@ -265,12 +269,12 @@ describe('toGatewayTargetSpec — lambda', () => {
265269 const onProgress = vi . fn ( ) ;
266270 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
267271
268- expect ( result ) . toBeDefined ( ) ;
269- expect ( result ! . name ) . toBe ( 'test_target' ) ;
270- expect ( result ! . targetType ) . toBe ( 'lambdaFunctionArn' ) ;
272+ assert ( result . success ) ;
273+ expect ( result . target ! . name ) . toBe ( 'test_target' ) ;
274+ expect ( result . target ! . targetType ) . toBe ( 'lambdaFunctionArn' ) ;
271275
272276 // eslint-disable-next-line @typescript-eslint/no-explicit-any
273- const lambdaConfig = ( result as any ) . lambdaFunctionArn ;
277+ const lambdaConfig = ( result . target as any ) . lambdaFunctionArn ;
274278 expect ( lambdaConfig . lambdaArn ) . toBe ( 'arn:aws:lambda:us-west-2:123456789012:function:my-func' ) ;
275279 expect ( lambdaConfig . toolSchemaFile ) . toBe ( 's3://schemas/tools.json' ) ;
276280 } ) ;
@@ -290,7 +294,8 @@ describe('toGatewayTargetSpec — lambda', () => {
290294 const onProgress = vi . fn ( ) ;
291295 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
292296
293- expect ( result ) . toBeUndefined ( ) ;
297+ assert ( result . success ) ;
298+ expect ( result . target ) . toBeUndefined ( ) ;
294299 expect ( onProgress ) . toHaveBeenCalledWith ( expect . stringContaining ( '(lambda) has no ARN, skipping' ) ) ;
295300 } ) ;
296301
@@ -309,7 +314,8 @@ describe('toGatewayTargetSpec — lambda', () => {
309314 const onProgress = vi . fn ( ) ;
310315 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
311316
312- expect ( result ) . toBeUndefined ( ) ;
317+ assert ( result . success ) ;
318+ expect ( result . target ) . toBeUndefined ( ) ;
313319 expect ( onProgress ) . toHaveBeenCalledWith (
314320 expect . stringContaining ( 'has inline tool schema, which cannot be imported' )
315321 ) ;
@@ -349,7 +355,8 @@ describe('toGatewayTargetSpec — unrecognized target type', () => {
349355 const onProgress = vi . fn ( ) ;
350356 const result = toGatewayTargetSpec ( detail , new Map ( ) , onProgress ) ;
351357
352- expect ( result ) . toBeUndefined ( ) ;
358+ assert ( result . success ) ;
359+ expect ( result . target ) . toBeUndefined ( ) ;
353360 expect ( onProgress ) . toHaveBeenCalledWith ( expect . stringContaining ( 'unrecognized target type' ) ) ;
354361 } ) ;
355362} ) ;
0 commit comments