Родитель
436ad5fd65
Коммит
7bafb00f05
|
@ -151,6 +151,11 @@ namespace Microsoft.Extensions.SecretManager.Tools
|
|||
|
||||
var fileInfo = new PhysicalFileInfo(new FileInfo(projectPath));
|
||||
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
throw new GracefulException(Resources.FormatError_ProjectPath_NotFound(projectPath));
|
||||
}
|
||||
|
||||
Logger.LogDebug(Resources.Message_Project_File_Path, fileInfo.PhysicalPath);
|
||||
return ReadUserSecretsId(fileInfo);
|
||||
}
|
||||
|
|
|
@ -58,6 +58,22 @@ namespace Microsoft.Extensions.SecretManager.Tools
|
|||
return GetString("Error_No_Secrets_Found");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The project file '{path}' does not exist.
|
||||
/// </summary>
|
||||
internal static string Error_ProjectPath_NotFound
|
||||
{
|
||||
get { return GetString("Error_ProjectPath_NotFound"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The project file '{path}' does not exist.
|
||||
/// </summary>
|
||||
internal static string FormatError_ProjectPath_NotFound(object path)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, GetString("Error_ProjectPath_NotFound", "path"), path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Project file path {project}.
|
||||
/// </summary>
|
||||
|
|
|
@ -126,6 +126,9 @@
|
|||
<data name="Error_No_Secrets_Found" xml:space="preserve">
|
||||
<value>No secrets configured for this application.</value>
|
||||
</data>
|
||||
<data name="Error_ProjectPath_NotFound" xml:space="preserve">
|
||||
<value>The project file '{path}' does not exist.</value>
|
||||
</data>
|
||||
<data name="Message_Project_File_Path" xml:space="preserve">
|
||||
<value>Project file path {project}.</value>
|
||||
</data>
|
||||
|
|
|
@ -10,6 +10,7 @@ using Microsoft.Extensions.Configuration.UserSecrets.Tests;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Microsoft.Extensions.SecretManager.Tools.Internal;
|
||||
|
||||
namespace Microsoft.Extensions.SecretManager.Tools.Tests
|
||||
{
|
||||
|
@ -22,6 +23,17 @@ namespace Microsoft.Extensions.SecretManager.Tools.Tests
|
|||
_logger = new TestLogger(output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Error_Project_DoesNotExist()
|
||||
{
|
||||
var projectPath = Path.Combine(Path.GetTempPath(), "dne", Guid.NewGuid().ToString(), "project.json");
|
||||
var secretManager = new Program(Console.Out, Directory.GetCurrentDirectory()) { Logger = _logger };
|
||||
|
||||
var ex = Assert.Throws<GracefulException>(() => secretManager.RunInternal("list", "--project", projectPath));
|
||||
|
||||
Assert.Equal(ex.Message, Resources.FormatError_ProjectPath_NotFound(projectPath));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
|
|
Загрузка…
Ссылка в новой задаче