Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Nov 29, 2024
1 parent c9ad95c commit bba8a0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 17 additions & 1 deletion lib/modules/datasource/maven/s3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ describe('modules/datasource/maven/s3', () => {
Bucket: 'repobucket',
Key: 'org/example/package/maven-metadata.xml',
})
.resolvesOnce({ Body: meta as never });
.resolvesOnce({
Body: meta as never,
LastModified: new Date('2020-01-01T00:00Z'),
});

const res = await get('org.example:package', baseUrlS3);

Expand Down Expand Up @@ -150,6 +153,19 @@ describe('modules/datasource/maven/s3', () => {
);
});

it('returns null for Deleted marker', async () => {
s3mock
.on(GetObjectCommand, {
Bucket: 'repobucket',
Key: 'org/example/package/maven-metadata.xml',
})
.resolvesOnce({ DeleteMarker: true });

const res = await get('org.example:package', baseUrlS3);

expect(res).toBeNull();
});

it('returns null for unknown error', async () => {
s3mock
.on(GetObjectCommand, {
Expand Down
2 changes: 0 additions & 2 deletions lib/modules/datasource/maven/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ export async function downloadS3Protocol(
LastModified,
DeleteMarker,
}): Promise<MavenFetchResult> => {
// istanbul ignore if: will be covered later
if (DeleteMarker) {
return Result.err({ type: 'not-found' });
}
Expand All @@ -178,7 +177,6 @@ export async function downloadS3Protocol(
const result: MavenFetchSuccess = { data };

const lastModified = normalizeDate(LastModified);
// istanbul ignore if: will be covered later
if (lastModified) {
result.lastModified = lastModified;
}
Expand Down

0 comments on commit bba8a0b

Please sign in to comment.