@@ -2,11 +2,10 @@ import { afterEach, describe, expect, test } from "bun:test";
22import { mkdir , mkdtemp , readdir , rm , writeFile } from "node:fs/promises" ;
33import { join , relative } from "node:path" ;
44import { tmpdir } from "node:os" ;
5- import { DeserializationError , InputValidationError , ProjectStateError } from "../../errors/errors" ;
5+ import { DeserializationError , ProjectStateError } from "../../errors/errors" ;
66import { FsProjectManager } from "./manager" ;
77import {
88 PROJECT_TEMPLATES ,
9- type AddResourceInput ,
109 type CreateProjectInput ,
1110 type Project ,
1211 type ProjectEvent ,
@@ -63,21 +62,6 @@ async function runCreate(
6362 }
6463}
6564
66- async function runAdd (
67- subject : FsProjectManager ,
68- project : Project ,
69- input : AddResourceInput ,
70- ) : Promise < { events : ProjectEvent [ ] ; project : Project } > {
71- const iterator = subject . addResource ( project , input ) ;
72- const events : ProjectEvent [ ] = [ ] ;
73-
74- while ( true ) {
75- const next = await iterator . next ( ) ;
76- if ( next . done ) return { events, project : next . value } ;
77- events . push ( next . value ) ;
78- }
79- }
80-
8165describe ( "FsProjectManager.create" , ( ) => {
8266 test ( "scaffolds the expected file tree into a fresh directory" , async ( ) => {
8367 const directory = await inTempDirectory ( ) ;
@@ -375,78 +359,3 @@ describe("FsProjectManager.resolve", () => {
375359 ) ;
376360 } ) ;
377361} ) ;
378-
379- describe ( "FsProjectManager.addResource" , ( ) => {
380- async function projectWithGateway ( subject : FsProjectManager ) : Promise < Project > {
381- const { project } = await runCreate ( subject , {
382- name : "example" ,
383- template : PROJECT_TEMPLATES . HELLO_WORLD_PYTHON ,
384- skipInstall : true ,
385- skipGit : true ,
386- } ) ;
387- return (
388- await runAdd ( subject , project , {
389- resourceType : "gateway" ,
390- resourceConfig : {
391- name : "tools" ,
392- protocolType : "None" ,
393- authorizerType : "NONE" ,
394- targets : [ ] ,
395- enableSemanticSearch : false ,
396- exceptionLevel : "NONE" ,
397- } ,
398- } )
399- ) . project ;
400- }
401-
402- test ( "adds a Target using its project-schema shape without creating assets" , async ( ) => {
403- const directory = await inTempDirectory ( ) ;
404- const subject = manager ( ) . manager ;
405- const project = await projectWithGateway ( subject ) ;
406-
407- const result = await runAdd ( subject , project , {
408- resourceType : "gateway-target" ,
409- gatewayName : "tools" ,
410- resourceConfig : {
411- name : "search" ,
412- targetType : "lambdaFunctionArn" ,
413- lambdaFunctionArn : {
414- lambdaArn : "arn:aws:lambda:us-east-1:123456789012:function:search" ,
415- toolSchemaFile : "schemas/tool-schema.json" ,
416- } ,
417- } ,
418- } ) ;
419-
420- expect ( result . project . spec . agentCoreGateways [ 0 ] ?. targets [ 0 ] ) . toEqual ( {
421- name : "search" ,
422- targetType : "lambdaFunctionArn" ,
423- lambdaFunctionArn : {
424- lambdaArn : "arn:aws:lambda:us-east-1:123456789012:function:search" ,
425- toolSchemaFile : "schemas/tool-schema.json" ,
426- } ,
427- } ) ;
428- expect ( await Bun . file ( join ( directory , "example" , "agentcore" , "assets" ) ) . exists ( ) ) . toBe ( false ) ;
429- } ) ;
430-
431- test ( "rejects an invalid project Target before writing the project" , async ( ) => {
432- const directory = await inTempDirectory ( ) ;
433- const subject = manager ( ) . manager ;
434- const project = await projectWithGateway ( subject ) ;
435-
436- await expect (
437- runAdd ( subject , project , {
438- resourceType : "gateway-target" ,
439- gatewayName : "tools" ,
440- resourceConfig : {
441- name : "search" ,
442- targetType : "openApiSchema" ,
443- } as never ,
444- } ) ,
445- ) . rejects . toBeInstanceOf ( InputValidationError ) ;
446-
447- const persisted = await Bun . file (
448- join ( directory , "example" , "agentcore" , "agentcore.json" ) ,
449- ) . json ( ) ;
450- expect ( persisted . agentCoreGateways [ 0 ] . targets ) . toEqual ( [ ] ) ;
451- } ) ;
452- } ) ;
0 commit comments