Skip to content

Commit

Permalink
Unit test case fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Viji committed Sep 20, 2024
1 parent 328d213 commit b008177
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/AritfactoryUploader.UTest/ArtifactoryUploaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,10 @@ public async Task UploadPackageToRepo_WhenPackageTypeIsClearedThirdPartyOrDevelo
ArtfactoryUploader.jFrogService = jFrogServiceMock.Object;
ArtfactoryUploader.JFrogApiCommInstance = jfrogApicommunicationMock.Object;
// Act
var response = await ArtfactoryUploader.UploadPackageToRepo(component, timeout, displayPackagesInfo);
_= await ArtfactoryUploader.UploadPackageToRepo(component, timeout, displayPackagesInfo);

// Assert
jfrogApicommunicationMock.Verify(x => x.CopyFromRemoteRepo(component), Times.Once);
//Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
}

[Test]
Expand Down
49 changes: 48 additions & 1 deletion src/AritfactoryUploader.UTest/PackageUploadHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Threading.Tasks;
using System.Linq;
using LCT.ArtifactoryUploader.Model;
using LCT.APICommunications;

namespace AritfactoryUploader.UTest
{
Expand Down Expand Up @@ -140,7 +141,7 @@ public async Task GetComponentsToBeUploadedToArtifactory_GivenNotApprovedCompone
};

//Act
List<ComponentsToArtifactory> uploadList =await PackageUploadHelper.GetComponentsToBeUploadedToArtifactory(componentLists, appSettings, displayPackagesInfo);
List<ComponentsToArtifactory> uploadList = await PackageUploadHelper.GetComponentsToBeUploadedToArtifactory(componentLists, appSettings, displayPackagesInfo);

// Assert
Assert.That(0, Is.EqualTo(uploadList.Count), "Checks for components to upload to be zero");
Expand Down Expand Up @@ -197,6 +198,52 @@ public void UpdateBomArtifactoryRepoUrl_GivenBomAndComponentsUploadedToArtifacto
Assert.AreNotEqual("org1-npmjs-npm-remote", repoUrl);
}

[Test]
public void DisplayErrorForJfrogPackages_GivenJfrogNotFoundPackages_ResultsSucess()
{
// Arrange
ComponentsToArtifactory componentsToArtifactory = new ComponentsToArtifactory();
componentsToArtifactory.Name = "Test";
componentsToArtifactory.Version = "0.12.3";
List<ComponentsToArtifactory> JfrogNotFoundPackages = new() { componentsToArtifactory };
// Act

PackageUploadHelper.DisplayErrorForJfrogPackages(JfrogNotFoundPackages);

// Assert
}

[Test]
public void DisplayErrorForJfrogFoundPackages_GivenJfrogNotFoundPackages_ResultsSucess()
{
// Arrange
ComponentsToArtifactory componentsToArtifactory = new ComponentsToArtifactory();
componentsToArtifactory.Name = "Test";
componentsToArtifactory.Version = "0.12.3";
componentsToArtifactory.ResponseMessage = new System.Net.Http.HttpResponseMessage()
{ ReasonPhrase = ApiConstant.ErrorInUpload };

ComponentsToArtifactory componentsToArtifactory2 = new ComponentsToArtifactory();
componentsToArtifactory2.Name = "Test2";
componentsToArtifactory2.Version = "0.12.32";
componentsToArtifactory2.ResponseMessage = new System.Net.Http.HttpResponseMessage()
{ ReasonPhrase = ApiConstant.PackageNotFound };

ComponentsToArtifactory componentsToArtifactory3 = new ComponentsToArtifactory();
componentsToArtifactory3.Name = "Test3";
componentsToArtifactory3.Version = "0.12.33";
componentsToArtifactory3.ResponseMessage = new System.Net.Http.HttpResponseMessage()
{ ReasonPhrase = "error" };

List<ComponentsToArtifactory> JfrogNotFoundPackages = new() {
componentsToArtifactory, componentsToArtifactory2, componentsToArtifactory3 };
// Act

PackageUploadHelper.DisplayErrorForJfrogFoundPackages(JfrogNotFoundPackages);

// Assert
}

private static List<Component> GetComponentList()
{
List<Component> componentLists = new List<Component>();
Expand Down
4 changes: 2 additions & 2 deletions src/ArtifactoryUploader/PackageUploadHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private static void DisplaySortedForeachComponents(List<ComponentsToArtifactory>

}

private static void DisplayErrorForJfrogFoundPackages(List<ComponentsToArtifactory> JfrogFoundPackages)
public static void DisplayErrorForJfrogFoundPackages(List<ComponentsToArtifactory> JfrogFoundPackages)
{

if (JfrogFoundPackages.Any())
Expand Down Expand Up @@ -196,7 +196,7 @@ private static void DisplayErrorForJfrogFoundPackages(List<ComponentsToArtifacto
}
}

private static void DisplayErrorForJfrogPackages(List<ComponentsToArtifactory> JfrogNotFoundPackages)
public static void DisplayErrorForJfrogPackages(List<ComponentsToArtifactory> JfrogNotFoundPackages)
{

if (JfrogNotFoundPackages.Any())
Expand Down
6 changes: 0 additions & 6 deletions src/SW360IntegrationTest/NPM/ClearingToolLoadTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace SW360IntegrationTest.LoadTest
{
[Ignore("Load test need to run separatly")]
[TestFixture, Order(11)]
public class ClearingToolLoadTest
{
private string OutFolderPath { get; set; }
Expand All @@ -23,8 +21,6 @@ public void Setup()
OutFolderPath = TestHelper.OutFolder;
}

[Ignore("Load test need to run separatly")]
[Test, Order(1)]
public void PerformanceTestFor130Components()
{
//Arrange
Expand All @@ -46,8 +42,6 @@ public void PerformanceTestFor130Components()
$"The actual time taken : {stopwatch.Elapsed.Minutes} is not equal to expected,which is 200 min");
}

[Ignore("Load test need to run separatly")]
[Test, Order(2)]
public void PerformanceTestFor70Components()
{
//Arrange
Expand Down

0 comments on commit b008177

Please sign in to comment.