forked from projectkudu/kudu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SyncTriggers for regular ZipDeploy functions
- Loading branch information
1 parent
3d478a2
commit 54fb4ec
Showing
4 changed files
with
99 additions
and
4 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
Kudu.Core.Test/Deployment/PushDeploymentControllerFacts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System; | ||
using System.IO; | ||
using System.IO.Abstractions; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Kudu.Contracts.Settings; | ||
using Kudu.Contracts.Tracing; | ||
using Kudu.Core.Deployment; | ||
using Kudu.Core.Infrastructure; | ||
using Kudu.Core.Tracing; | ||
using Kudu.Services.Deployment; | ||
using Moq; | ||
using Xunit; | ||
|
||
namespace Kudu.Core.Test.Deployment | ||
{ | ||
public class PushDeploymentControllerFacts | ||
{ | ||
[Fact] | ||
public async Task ZipDeployInRunFromZipSetsZipNameAndSyncTriggersPath() | ||
{ | ||
// Setup | ||
var environment = new Mock<IEnvironment>(); | ||
var deploymentManager = new Mock<IFetchDeploymentManager>(); | ||
var tracer = new Mock<ITracer>(); | ||
var traceFactory = new Mock<ITraceFactory>(); | ||
var settings = new Mock<IDeploymentSettingsManager>(); | ||
var fileSystem = new Mock<IFileSystem>(); | ||
var fileBase = new Mock<FileBase>(); | ||
var directoryBase = new Mock<DirectoryBase>(); | ||
var fileStream = new MemoryStream(); | ||
var requestStream = new MemoryStream(Encoding.UTF8.GetBytes("Request Body")); | ||
|
||
settings | ||
.Setup(s => s.GetValue(It.Is<string>(t => t == SettingsKeys.RunFromZip), It.IsAny<bool>())) | ||
.Returns("1"); | ||
|
||
environment | ||
.SetupGet(e => e.SitePackagesPath) | ||
.Returns(@"x:\data"); | ||
|
||
fileBase | ||
.Setup(f => f.Create(It.IsAny<string>())) | ||
.Returns(fileStream); | ||
directoryBase | ||
.Setup(d => d.Exists(It.IsAny<string>())) | ||
.Returns(true); | ||
|
||
fileSystem.SetupGet(f => f.File).Returns(fileBase.Object); | ||
fileSystem.SetupGet(f => f.Directory).Returns(directoryBase.Object); | ||
|
||
FileSystemHelpers.Instance = fileSystem.Object; | ||
|
||
deploymentManager | ||
.Setup(m => m.FetchDeploy(It.IsAny<ZipDeploymentInfo>(), It.IsAny<bool>(), It.IsAny<Uri>(), It.IsAny<string>())) | ||
.Returns(Task.FromResult(FetchDeploymentRequestResult.RanSynchronously)); | ||
|
||
var controller = new PushDeploymentController( | ||
environment.Object, | ||
deploymentManager.Object, | ||
tracer.Object, | ||
traceFactory.Object, | ||
settings.Object) | ||
{ | ||
Request = new HttpRequestMessage(HttpMethod.Post, "https://localhost/zipDeploy") | ||
{ | ||
Content = new StreamContent(requestStream) | ||
} | ||
}; | ||
|
||
// Act | ||
var response = await controller.ZipPushDeploy(); | ||
|
||
// Assert | ||
deploymentManager | ||
.Verify(m => m.FetchDeploy(It.Is<ZipDeploymentInfo>(di => | ||
!string.IsNullOrEmpty(di.ZipName) && !string.IsNullOrEmpty(di.SyncFunctionsTriggersPath)), | ||
It.IsAny<bool>(), | ||
It.IsAny<Uri>(), | ||
It.IsAny<string>() | ||
)); | ||
|
||
Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters