Skip to content

Commit 0815c28

Browse files
committed
Merge pull request #1917 from eocrawford/users/ethancr/bugfixes
Check fullSetParametersFile for null before attempting a Path.Combine
2 parents 4388602 + 4ef648a commit 0815c28

File tree

2 files changed

+57
-6
lines changed

2 files changed

+57
-6
lines changed

src/ServiceManagement/Services/Commands.Test/Websites/PublishAzureWebsiteProjectTests.cs

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,72 @@
1-
using System.Collections;
2-
using System.IO;
1+
using System;
2+
using System.Collections;
33
using System.Management.Automation;
4+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
45
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
56
using Microsoft.WindowsAzure.Commands.Test.Utilities.Websites;
7+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
68
using Microsoft.WindowsAzure.Commands.Utilities.Websites;
79
using Microsoft.WindowsAzure.Commands.Websites;
810
using Microsoft.WindowsAzure.Management.WebSites.Models;
911
using Moq;
10-
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1112
using Xunit;
12-
using System;
13-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
1413

1514
namespace Microsoft.WindowsAzure.Commands.Test.Websites
1615
{
1716
public class PublishAzureWebsiteProjectTests : WebsitesTestBase
1817
{
18+
[Fact]
19+
[Trait(Category.AcceptanceType, Category.CheckIn)]
20+
public void PublishFromPackageWithoutSetParameters()
21+
{
22+
const string websiteName = "test-site";
23+
const string package = "test-package";
24+
string slot = null;
25+
var connectionStrings = new Hashtable();
26+
connectionStrings["DefaultConnection"] = "test-connection-string";
27+
28+
var publishProfile = new WebSiteGetPublishProfileResponse.PublishProfile
29+
{
30+
UserName = "test-user-name",
31+
UserPassword = "test-password",
32+
PublishUrl = "test-publish-url"
33+
};
34+
35+
var published = false;
36+
37+
var clientMock = new Mock<IWebsitesClient>();
38+
39+
clientMock.Setup(c => c.GetWebDeployPublishProfile(websiteName, slot)).Returns(publishProfile);
40+
clientMock.Setup(c => c.PublishWebProject(websiteName, slot, package, null, connectionStrings, false, false))
41+
.Callback((string n, string s, string p, string spf, Hashtable cs, bool skipAppData, bool doNotDelete) =>
42+
{
43+
Assert.Equal(websiteName, n);
44+
Assert.Equal(slot, s);
45+
Assert.Equal(package, p);
46+
Assert.Equal(connectionStrings, cs);
47+
Assert.False(skipAppData);
48+
Assert.False(doNotDelete);
49+
published = true;
50+
});
51+
52+
var powerShellMock = new Mock<ICommandRuntime>();
53+
54+
var command = new PublishAzureWebsiteProject
55+
{
56+
CommandRuntime = powerShellMock.Object,
57+
Name = websiteName,
58+
Package = package,
59+
ConnectionString = connectionStrings,
60+
WebsitesClient = clientMock.Object,
61+
SetParametersFile = null
62+
};
63+
64+
command.ExecuteCmdlet();
65+
66+
powerShellMock.Verify(f => f.WriteVerbose(string.Format("[Complete] Publishing package {0}", package)), Times.Once());
67+
Assert.True(published);
68+
}
69+
1970
[Fact]
2071
[Trait(Category.AcceptanceType, Category.CheckIn)]
2172
public void PublishFromPackage()

src/ServiceManagement/Services/Commands/Websites/PublishAzureWebsiteProject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public override void ExecuteCmdlet()
8787
}
8888
}
8989

90-
if (!File.Exists(fullSetParametersFile))
90+
if (!string.IsNullOrEmpty(fullSetParametersFile) && !File.Exists(fullSetParametersFile))
9191
{
9292
if (File.Exists(Path.Combine(Path.GetDirectoryName(fullPackage), fullSetParametersFile)))
9393
{

0 commit comments

Comments
 (0)