Skip to content

Commit eaf25df

Browse files
committed
changes based on review
1 parent 223c7c4 commit eaf25df

File tree

10 files changed

+15
-31
lines changed

10 files changed

+15
-31
lines changed

src/WebJobs.Script.WebHost/Management/FunctionsSyncManager.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ internal bool ArmCacheEnabled
9292
}
9393
}
9494

95-
public async Task<SyncTriggersResult> TrySyncTriggersAsync(bool isBackgroundSync = false)
95+
public async Task<TriggersOperationResult> TrySyncTriggersAsync(bool isBackgroundSync = false)
9696
{
97-
var result = new SyncTriggersResult
97+
var result = new TriggersOperationResult
9898
{
9999
Success = true
100100
};
@@ -808,12 +808,8 @@ public async Task<GetTriggersResult> GetTriggersPayloadAsync()
808808
PrepareSyncTriggers();
809809

810810
var payload = await GetSyncTriggersPayload();
811-
if (payload.Count == 0)
812-
{
813-
_logger.LogDebug("No functions found in GetTriggers operation.");
814-
}
815811

816-
result.Payload = payload;
812+
result.Content = payload.Content;
817813
return result;
818814
}
819815
catch (Exception ex)
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using static Microsoft.Azure.WebJobs.Script.WebHost.Management.FunctionsSyncManager;
5-
64
namespace Microsoft.Azure.WebJobs.Script.WebHost.Management
75
{
8-
public class GetTriggersResult
6+
public class GetTriggersResult : TriggersOperationResult
97
{
10-
/// <summary>
11-
/// Gets or sets a value indicating whether the operation was successful.
12-
/// </summary>
13-
public bool Success { get; set; }
14-
15-
/// <summary>
16-
/// Gets or sets the error string in the case of a failed operation.
17-
/// </summary>
18-
public string Error { get; set; }
19-
208
/// <summary>
219
/// Gets or sets the triggers payload.
2210
/// </summary>
23-
public SyncTriggersPayload Payload { get; set; }
11+
public string Content { get; set; }
2412
}
2513
}

src/WebJobs.Script.WebHost/Management/IFunctionsSyncManager.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public interface IFunctionsSyncManager
1111
/// Sync function triggers with Antares infrastructure.
1212
/// </summary>
1313
/// <param name="isBackgroundSync">Indicates whether this is a background sync operation.</param>
14-
/// <returns>The <see cref="SyncTriggersResult"/> for the request.</returns>
15-
Task<SyncTriggersResult> TrySyncTriggersAsync(bool isBackgroundSync = false);
14+
/// <returns>The <see cref="TriggersOperationResult"/> for the request.</returns>
15+
Task<TriggersOperationResult> TrySyncTriggersAsync(bool isBackgroundSync = false);
1616

1717
/// <summary>
1818
/// Get function triggers payload.

src/WebJobs.Script.WebHost/Management/SyncTriggersResult.cs renamed to src/WebJobs.Script.WebHost/Management/TriggersOperationResult.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Microsoft.Azure.WebJobs.Script.WebHost.Management
55
{
6-
public class SyncTriggersResult
6+
public class TriggersOperationResult
77
{
88
/// <summary>
99
/// Gets or sets a value indicating whether the sync operation was successful.

test/WebJobs.Script.Tests.Integration/Management/FunctionsSyncManagerTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ public async Task GetTriggersPayload_ExpectedContent()
265265
// Assert
266266
Assert.True(result.Success);
267267
Assert.Null(result.Error);
268-
Assert.NotNull(result.Payload);
268+
Assert.NotNull(result.Content);
269269

270-
var content = JObject.Parse(result.Payload.Content);
270+
var content = JObject.Parse(result.Content);
271271
var triggers = content["triggers"];
272272
Assert.Equal(GetExpectedTriggersPayload(durableVersion: "V1"), triggers.ToString(Formatting.None));
273273
}

test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/CodelessEndToEndTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ private TestFunctionHost StartLocalHost(string baseTestPath, string sourceFuncti
244244
string testLogPath = Path.Combine(baseTestPath, "Logs");
245245

246246
var syncTriggerMock = new Mock<IFunctionsSyncManager>(MockBehavior.Strict);
247-
syncTriggerMock.Setup(p => p.TrySyncTriggersAsync(It.IsAny<bool>())).ReturnsAsync(new SyncTriggersResult { Success = true });
247+
syncTriggerMock.Setup(p => p.TrySyncTriggersAsync(It.IsAny<bool>())).ReturnsAsync(new TriggersOperationResult { Success = true });
248248

249249
FileUtility.CopyDirectory(sourceFunctionApp, appContent);
250250
var host = new TestFunctionHost(sourceFunctionApp, testLogPath,

test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/EndToEndTestFixture.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ string GetDestPath(int counter)
148148
}
149149

150150
FunctionsSyncManagerMock = new Mock<IFunctionsSyncManager>(MockBehavior.Strict);
151-
FunctionsSyncManagerMock.Setup(p => p.TrySyncTriggersAsync(It.IsAny<bool>())).ReturnsAsync(new SyncTriggersResult { Success = true });
151+
FunctionsSyncManagerMock.Setup(p => p.TrySyncTriggersAsync(It.IsAny<bool>())).ReturnsAsync(new TriggersOperationResult { Success = true });
152152

153153
string azuriteConnectionString = _azurite.GetConnectionString();
154154
Host = new TestFunctionHost(_copiedRootPath, logPath, addTestSettings: _addTestSettings,

test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/MultiLanguageEndToEndTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private TestFunctionHost StartLocalHost(string baseTestPath, string sourceFuncti
199199
string testLogPath = Path.Combine(baseTestPath, "Logs");
200200

201201
var syncTriggerMock = new Mock<IFunctionsSyncManager>(MockBehavior.Strict);
202-
syncTriggerMock.Setup(p => p.TrySyncTriggersAsync(It.IsAny<bool>())).ReturnsAsync(new SyncTriggersResult { Success = true });
202+
syncTriggerMock.Setup(p => p.TrySyncTriggersAsync(It.IsAny<bool>())).ReturnsAsync(new TriggersOperationResult { Success = true });
203203

204204
FileUtility.CopyDirectory(sourceFunctionApp, appContent);
205205
var host = new TestFunctionHost(sourceFunctionApp, testLogPath,

test/WebJobs.Script.Tests/Controllers/Admin/KeysControllerTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public KeysControllerTests()
6262
fileBase.Setup(f => f.ReadAllText(Path.Combine(rootScriptPath, "DNE", ScriptConstants.FunctionMetadataFileName))).Throws(new DirectoryNotFoundException());
6363

6464
_functionsSyncManagerMock = new Mock<IFunctionsSyncManager>(MockBehavior.Strict);
65-
_functionsSyncManagerMock.Setup(p => p.TrySyncTriggersAsync(false)).ReturnsAsync(new SyncTriggersResult { Success = true });
65+
_functionsSyncManagerMock.Setup(p => p.TrySyncTriggersAsync(false)).ReturnsAsync(new TriggersOperationResult { Success = true });
6666

6767
var hostManagerMock = new Mock<IScriptHostManager>(MockBehavior.Strict);
6868
hostManagerMock.SetupGet(p => p.State).Returns(ScriptHostState.Running);

test/WebJobs.Script.Tests/FunctionsSyncServiceTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void ShouldSyncTriggers_ReturnsExpectedResult(bool isPrimary, ScriptHostS
6767
public async Task StartAsync_PrimaryHost_Running_SyncsTriggers_AfterTimeout()
6868
{
6969
TaskCompletionSource syncTriggers = new TaskCompletionSource();
70-
_mockSyncManager.Setup(p => p.TrySyncTriggersAsync(true)).ReturnsAsync(new SyncTriggersResult { Success = true }).Callback(() => syncTriggers.TrySetResult());
70+
_mockSyncManager.Setup(p => p.TrySyncTriggersAsync(true)).ReturnsAsync(new TriggersOperationResult { Success = true }).Callback(() => syncTriggers.TrySetResult());
7171

7272
await _syncService.StartAsync(CancellationToken.None);
7373

0 commit comments

Comments
 (0)