Esempio n. 1
0
        public async Task GetRecipeDefinitionPaths()
        {
            // Arrange
            var saveCdkDirectoryFullPath  = Path.Combine(_targetApplicationDirectoryFullPath, "DeploymentProjects", "MyCdkApp");
            var saveCdkDirectoryFullPath2 = Path.Combine(_targetApplicationDirectoryFullPath, "DeploymentProjects", "MyCdkApp2");
            var saveCdkDirectoryFullPath3 = Path.Combine(_targetApplicationDirectoryFullPath, "DeploymentProjects", "MyCdkApp3");

            _testDirectoryManager.CreateDirectory(saveCdkDirectoryFullPath);
            _testDirectoryManager.CreateDirectory(saveCdkDirectoryFullPath2);
            _testDirectoryManager.CreateDirectory(saveCdkDirectoryFullPath3);

            await _deploymentManifestEngine.UpdateDeploymentManifestFile(saveCdkDirectoryFullPath, _targetApplicationFullPath);

            await _deploymentManifestEngine.UpdateDeploymentManifestFile(saveCdkDirectoryFullPath2, _targetApplicationFullPath);

            await _deploymentManifestEngine.UpdateDeploymentManifestFile(saveCdkDirectoryFullPath3, _targetApplicationFullPath);

            var deploymentManifestFilePath = Path.Combine(_targetApplicationDirectoryFullPath, "aws-deployments.json");

            // Act
            var recipeDefinitionPaths = await _deploymentManifestEngine.GetRecipeDefinitionPaths(_targetApplicationFullPath);

            // Assert
            Assert.True(_fileManager.Exists(deploymentManifestFilePath));
            recipeDefinitionPaths.Count.ShouldEqual(3);
            recipeDefinitionPaths.ShouldContain(saveCdkDirectoryFullPath);
            recipeDefinitionPaths.ShouldContain(saveCdkDirectoryFullPath2);
            recipeDefinitionPaths.ShouldContain(saveCdkDirectoryFullPath3);

            // cleanup
            File.Delete(deploymentManifestFilePath);
            Assert.False(_fileManager.Exists(deploymentManifestFilePath));
        }
 /// <summary>
 /// Fetches recipe definition paths by parsing the deployment-manifest file that is associated with the target application.
 /// </summary>
 /// <param name="targetApplicationFullPath">The absolute path to the target application csproj or fsproj file</param>
 /// <returns>A list containing absolute paths to the saved CDK deployment projects</returns>
 private async Task <List <string> > LocateRecipePathsFromManifestFile(string targetApplicationFullPath)
 {
     try
     {
         return(await _deploymentManifestEngine.GetRecipeDefinitionPaths(targetApplicationFullPath));
     }
     catch
     {
         _orchestratorInteractiveService.LogMessageLine(Environment.NewLine);
         _orchestratorInteractiveService.LogErrorMessageLine("Failed to load custom deployment recommendations " +
                                                             "from the deployment-manifest file due to an error while trying to deserialze the file.");
         return(await Task.FromResult(new List <string>()));
     }
 }