Skip to content

Commit

Permalink
test: added test for not adding dependencies that can not be found on…
Browse files Browse the repository at this point in the history
… any server
  • Loading branch information
iadonkey committed Dec 11, 2024
1 parent dc66d0e commit b33cf2b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions TwinpackCore/Core/TwinpackService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ private async Task<List<PackageItem>> AffectedPackagesAsync(List<PackageItem> pa
{
if (package.Package == null || package.PackageVersion == null || package.PackageServer == null)
{
package.Package = null;
package.PackageVersion = null;
package.PackageServer = null;
var resolvedPackage = await _packageServers.FetchPackageAsync(package.PackageServer, package.ProjectName, package.PlcName, package.Config, includeMetadata: true, _automationInterface, cancellationToken);
Expand Down
20 changes: 20 additions & 0 deletions TwinpackTests/TwinpackServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,5 +1387,25 @@ public async Task AffectedPackages_PreferPassedPackageItems()
Assert.AreEqual("ZPlatform", platformPackage.PackageVersion.Name);
Assert.AreEqual("main", platformPackage.PackageVersion.Branch);
}

[TestMethod]
public async Task AffectedPackages_IgnoreNotAvailableDependencies()
{
var twinpack = BuildMultiBranchDependencies();

var packages = await twinpack.AffectedPackagesAsync(
new List<PackageItem>()
{
new PackageItem()
{
Config = new ConfigPlcPackage { Name = "NotExisting", Version = "1.5.0.1", Branch = "main" },
Package = new PackageGetResponse { Name = "NotExisting" },
PackageVersion = new PackageVersionGetResponse { Name = "NotExisting", Version = "1.5.0.1", Branch = "main" },
PackageServer = null
},
});

Assert.AreEqual(0, packages.Count());
}
}
}

0 comments on commit b33cf2b

Please sign in to comment.