Skip to content

Commit

Permalink
Merge pull request #4 from DiSSCo/feature/small-fixes
Browse files Browse the repository at this point in the history
Fix test
  • Loading branch information
samleeflang authored Apr 3, 2024
2 parents d549866 + 6c5b192 commit a7c14e0
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import software.amazon.awssdk.services.s3.model.BucketAlreadyOwnedByYouException;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import software.amazon.awssdk.services.s3.model.ListObjectsResponse;
import software.amazon.awssdk.services.s3.model.NoSuchBucketException;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
import software.amazon.awssdk.services.s3.model.S3Object;
import software.amazon.awssdk.transfer.s3.S3TransferManager;
Expand Down Expand Up @@ -56,8 +57,6 @@ void setup() {
void testUploadIndex() {
// Given
String indexLocation = "src/test/resources/index";
given(s3Client.createBucket(any(Consumer.class))).willThrow(
BucketAlreadyOwnedByYouException.class);
var dirUpload = mock(DirectoryUpload.class);
given(transferManager.uploadDirectory(any(Consumer.class))).willReturn(dirUpload);
given(dirUpload.completionFuture()).willReturn(CompletableFuture.completedFuture(
Expand All @@ -71,8 +70,6 @@ void testUploadIndex() {
void testUploadIndexFailed() {
// Given
String indexLocation = "src/test/resources/index";
given(s3Client.createBucket(any(Consumer.class))).willThrow(
BucketAlreadyOwnedByYouException.class);
var dirUpload = mock(DirectoryUpload.class);
given(transferManager.uploadDirectory(any(Consumer.class))).willReturn(dirUpload);
given(dirUpload.completionFuture()).willReturn(CompletableFuture.completedFuture(
Expand All @@ -89,6 +86,17 @@ void testUploadIndexFailed() {
() -> s3StorageRepository.uploadIndex(indexLocation));
}

@Test
void testUploadBucketNotExsists() {
// Given
String indexLocation = "src/test/resources/index";
given(s3Client.headBucket(any(Consumer.class))).willThrow(NoSuchBucketException.class);

// When/Then
assertThrows(IndexingFailedException.class,
() -> s3StorageRepository.uploadIndex(indexLocation));
}

@Test
void testDownloadIndex() {
// Given
Expand Down

0 comments on commit a7c14e0

Please sign in to comment.