Improves unsupported Cloud Foundry service message

[#37]
This message is specific to Cloud Foundry.  Making a more generic
handling of this error will require a more substantial rewrite.
This commit is contained in:
Chris Cheetham 2019-10-03 14:35:23 -04:00
Родитель b8091fb7b3
Коммит d11f2c64cb
2 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -99,7 +99,12 @@ namespace Steeltoe.Tooling.Drivers.CloudFoundry
public void DeployService(string service)
{
var svcInfo = _context.Configuration.GetServiceInfo(service);
var cfServiceDef = _context.Target.Configuration.ServiceTypeProperties[svcInfo.ServiceType];
_context.Target.Configuration.ServiceTypeProperties.TryGetValue(svcInfo.ServiceType, out var cfServiceDef);
if (cfServiceDef == null)
{
throw new ToolingException($"No Cloud Foundry service available for '{svcInfo.Service}' [{svcInfo.ServiceType}]");
}
var cfCmd = $"create-service {cfServiceDef["service"]} {cfServiceDef["plan"]} {service}";
var svcArgs = _context.Configuration.GetServiceArgs(service, "cloud-foundry") ?? "";
if (svcArgs.Length > 0)

Просмотреть файл

@ -135,6 +135,15 @@ namespace Steeltoe.Tooling.Test.Drivers.CloudFoundry
Shell.LastCommand.ShouldBe("cf create-service p-redis shared-vm my-service");
}
[Fact]
public void TestDeployUnavailableService()
{
Context.Configuration.AddService("my-service", "zipkin");
var e = Assert.Throws<ToolingException>(
() => _driver.DeployService("my-service")
);
e.Message.ShouldBe("No Cloud Foundry service available for 'my-service' [zipkin]");
}
[Fact]
public void TestUndeployService()