Skip to content

Commit

Permalink
Fixing the Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MantavyaDh committed Dec 20, 2024
1 parent 12d2efd commit b9f7f27
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Test/L0/Worker/Build/BuildDirectoryManagerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ private TestHostContext Setup(
_variables.Set(Constants.Variables.System.DefinitionId, DefinitionId);
_variables.Set(Constants.Variables.Build.Clean, $"{cleanOption}");
_ec.Setup(x => x.Variables).Returns(_variables);
_ec.Setup(x => x.GetScopedEnvironment()).Returns(new SystemEnvironment());

// Store the expected tracking file path.
_trackingFile = Path.Combine(
Expand Down
2 changes: 2 additions & 0 deletions src/Test/L0/Worker/Build/BuildJobExtensionL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ private TestHostContext Setup([CallerMemberName] string name = "",
x.SetVariable(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>(), It.IsAny<bool>(), It.IsAny<bool>(), It.IsAny<bool>()))
.Callback((string varName, string varValue, bool isSecret, bool isOutput, bool isFilePath, bool isReadOnly, bool preserveCase) => { _variables.Set(varName, varValue, false); });

_ec.Setup(x => x.GetScopedEnvironment()).Returns(new SystemEnvironment());

_extensionManager.Setup(x => x.GetExtensions<ISourceProvider>())
.Returns(new List<ISourceProvider> { _sourceProvider.Object });

Expand Down
4 changes: 4 additions & 0 deletions src/Test/L0/Worker/Build/TrackingConfigL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.VisualStudio.Services.Agent.Worker.Build;
using Moq;
using Xunit;
using Agent.Sdk;

namespace Microsoft.VisualStudio.Services.Agent.Tests.Worker.Build
{
Expand Down Expand Up @@ -44,6 +45,7 @@ public void TrackingConfig_copy_legacy_ctor_should_fill_in_fields_correctly()
using (TestHostContext tc = Setup(out Mock<IExecutionContext> mockExecutionContext))
{
// Arrange.
mockExecutionContext.Setup(x => x.GetScopedEnvironment()).Returns(new SystemEnvironment());
var legacyConfig = new LegacyTrackingConfig
{
BuildDirectory = Path.Combine("path", "_work", "123"),
Expand Down Expand Up @@ -84,6 +86,7 @@ public void TrackingConfig_ctor_should_fill_in_fields_correctly()
{
using (TestHostContext tc = Setup(out Mock<IExecutionContext> mockExecutionContext))
{
mockExecutionContext.Setup(x => x.GetScopedEnvironment()).Returns(new SystemEnvironment());
// Arrange.
var repository = new RepositoryResource() { Type = RepositoryTypes.Git, Url = new Uri(RepositoryUrl) };

Expand Down Expand Up @@ -119,6 +122,7 @@ public void TrackingConfig_clone_should_fill_in_fields_correctly()
using (TestHostContext tc = Setup(out Mock<IExecutionContext> mockExecutionContext))
{
// Arrange.
mockExecutionContext.Setup(x => x.GetScopedEnvironment()).Returns(new SystemEnvironment());
var repository = new RepositoryResource() { Type = RepositoryTypes.Git, Url = new Uri(RepositoryUrl) };

// Act.
Expand Down
2 changes: 2 additions & 0 deletions src/Test/L0/Worker/Build/TrackingManagerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Text.RegularExpressions;
using Xunit;
using Agent.Sdk.Knob;
using Agent.Sdk;

namespace Microsoft.VisualStudio.Services.Agent.Tests.Worker.Build
{
Expand Down Expand Up @@ -49,6 +50,7 @@ public TestHostContext Setup([CallerMemberName] string name = "")
_variables.Set(Constants.Variables.System.DefinitionId, DefinitionId);
_variables.Set(Constants.Variables.Build.DefinitionName, DefinitionName);
_ec.Setup(x => x.Variables).Returns(_variables);
_ec.Setup(x => x.GetScopedEnvironment()).Returns(new SystemEnvironment());

// Setup the endpoint.
_repository = new Pipelines.RepositoryResource() { Url = new Uri(RepositoryUrl) };
Expand Down

0 comments on commit b9f7f27

Please sign in to comment.