Skip to content

Commit

Permalink
Merge pull request #655 from aws/dev
Browse files Browse the repository at this point in the history
chore: release 0.49
  • Loading branch information
philasmar authored Jun 28, 2022
2 parents c0581c2 + 2b99f96 commit 5ad959e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

using System;
using System.Collections.Generic;
using System.Text;
using AWS.Deploy.Orchestration.Utilities;

namespace AWS.Deploy.CLI.IntegrationTests.Helpers
{
public class TestEnvironmentVariableManager : IEnvironmentVariableManager
{
public readonly Dictionary<string, string> store = new Dictionary<string, string>();

public string GetEnvironmentVariable(string variable)
{
return store.ContainsKey(variable) ? store[variable] : null;
}

public void SetEnvironmentVariable(string variable, string value)
{
if (string.Equals(variable, "AWS_DOTNET_DEPLOYTOOL_WORKSPACE"))
store[variable] = value;
else
Environment.SetEnvironmentVariable(variable, value);
}
}
}
41 changes: 41 additions & 0 deletions test/AWS.Deploy.CLI.IntegrationTests/Helpers/Utilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using AWS.Deploy.Orchestration.Utilities;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace AWS.Deploy.CLI.IntegrationTests.Helpers
{
public static class Utilities
{
/// <summary>
/// This method sets a custom workspace which will be used by the deploy tool to create and run the CDK project and any temporary files during the deployment.
/// It also adds a nuget.config file that references a private nuget-cache. This cache holds the latest (in-development/unreleased) version of AWS.Deploy.Recipes.CDK.Common.nupkg file
/// </summary>
public static void OverrideDefaultWorkspace(ServiceProvider serviceProvider, string customWorkspace)
{
var environmentVariableManager = serviceProvider.GetRequiredService<IEnvironmentVariableManager>();
environmentVariableManager.SetEnvironmentVariable("AWS_DOTNET_DEPLOYTOOL_WORKSPACE", customWorkspace);
Directory.CreateDirectory(customWorkspace);

var nugetCachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".aws-dotnet-deploy", "Projects", "nuget-cache");
nugetCachePath = nugetCachePath.Replace(Path.DirectorySeparatorChar, '/');

var nugetConfigContent = $@"
<?xml version=""1.0"" encoding=""utf-8"" ?>
<configuration>
<packageSources>
<add key=""deploy-tool-cache"" value=""{nugetCachePath}"" />
</packageSources>
</configuration>
".Trim();

File.WriteAllText(Path.Combine(customWorkspace, "nuget.config"), nugetConfigContent);
}
}
}
22 changes: 1 addition & 21 deletions test/AWS.Deploy.CLI.IntegrationTests/WebAppNoDockerFileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public WebAppNoDockerFileTests()
var serviceProvider = serviceCollection.BuildServiceProvider();

_customWorkspace = Path.Combine(Path.GetTempPath(), $"deploy-tool-workspace{Guid.NewGuid().ToString().Split('-').Last()}");
var environmentVariableManager = serviceProvider.GetRequiredService<IEnvironmentVariableManager>();
environmentVariableManager.SetEnvironmentVariable("AWS_DOTNET_DEPLOYTOOL_WORKSPACE", _customWorkspace);
Directory.CreateDirectory(_customWorkspace);
Helpers.Utilities.OverrideDefaultWorkspace(serviceProvider, _customWorkspace);

_app = serviceProvider.GetService<App>();
Assert.NotNull(_app);
Expand Down Expand Up @@ -204,22 +202,4 @@ protected virtual void Dispose(bool disposing)
Dispose(false);
}
}

public class TestEnvironmentVariableManager : IEnvironmentVariableManager
{
public readonly Dictionary<string, string> store = new Dictionary<string, string>();

public string GetEnvironmentVariable(string variable)
{
return store.ContainsKey(variable) ? store[variable] : null;
}

public void SetEnvironmentVariable(string variable, string value)
{
if (string.Equals(variable, "AWS_DOTNET_DEPLOYTOOL_WORKSPACE"))
store[variable] = value;
else
Environment.SetEnvironmentVariable(variable, value);
}
}
}

0 comments on commit 5ad959e

Please sign in to comment.