-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Viji
committed
Sep 30, 2024
1 parent
e93bb7e
commit cd4f638
Showing
5 changed files
with
340 additions
and
9 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
using UnitTestUtilities; | ||
using LCT.ArtifactoryUploader.Model; | ||
using LCT.APICommunications.Model.AQL; | ||
using System; | ||
|
||
namespace AritfactoryUploader.UTest | ||
{ | ||
|
@@ -208,5 +209,64 @@ public async Task UploadPackageToRepo_WhenPackageTypeIsNotSupported_ReturnsNotFo | |
// Assert | ||
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); | ||
} | ||
[Test] | ||
public async Task UploadPackageToRepo_WhenHttpRequestExceptionOccurs_ReturnsErrorResponse() | ||
{ | ||
// Arrange | ||
var component = new ComponentsToArtifactory | ||
{ | ||
PackageType = PackageType.Unknown, | ||
ApiKey = "apiKey", | ||
Email = "[email protected]" | ||
}; | ||
component.SrcRepoName = ""; | ||
component.DestRepoName = ""; | ||
component.JfrogPackageName = ""; | ||
component.Path = ""; | ||
var timeout = 10000; | ||
var displayPackagesInfo = new DisplayPackagesInfo(); | ||
var jFrogServiceMock = new Mock<IJFrogService>(); | ||
var jfrogApicommunicationMock = new Mock<IJFrogApiCommunication>(); | ||
jFrogServiceMock.Setup(x => x.GetPackageInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) | ||
.ThrowsAsync(new HttpRequestException()); | ||
ArtfactoryUploader.jFrogService = jFrogServiceMock.Object; | ||
ArtfactoryUploader.JFrogApiCommInstance = jfrogApicommunicationMock.Object; | ||
|
||
// Act | ||
var response = await ArtfactoryUploader.UploadPackageToRepo(component, timeout, displayPackagesInfo); | ||
|
||
// Assert | ||
Assert.AreEqual(ApiConstant.ErrorInUpload, response.ReasonPhrase); | ||
} | ||
|
||
[Test] | ||
public async Task UploadPackageToRepo_WhenInvalidOperationExceptionOccurs_ReturnsErrorResponse() | ||
{ | ||
// Arrange | ||
var component = new ComponentsToArtifactory | ||
{ | ||
PackageType = PackageType.Unknown, | ||
ApiKey = "apiKey", | ||
Email = "[email protected]" | ||
}; | ||
component.SrcRepoName = ""; | ||
component.DestRepoName = ""; | ||
component.JfrogPackageName = ""; | ||
component.Path = ""; | ||
var timeout = 10000; | ||
var displayPackagesInfo = new DisplayPackagesInfo(); | ||
var jFrogServiceMock = new Mock<IJFrogService>(); | ||
var jfrogApicommunicationMock = new Mock<IJFrogApiCommunication>(); | ||
jFrogServiceMock.Setup(x => x.GetPackageInfo(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) | ||
.ThrowsAsync(new InvalidOperationException()); | ||
ArtfactoryUploader.jFrogService = jFrogServiceMock.Object; | ||
ArtfactoryUploader.JFrogApiCommInstance = jfrogApicommunicationMock.Object; | ||
|
||
// Act | ||
var response = await ArtfactoryUploader.UploadPackageToRepo(component, timeout, displayPackagesInfo); | ||
|
||
// Assert | ||
Assert.AreEqual(ApiConstant.ErrorInUpload, response.ReasonPhrase); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.