Skip to content

Commit

Permalink
refactor: use v3 sdk
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Maga <markus@maga.se>
  • Loading branch information
Flydiverny committed Dec 20, 2021
1 parent d9927c4 commit 5885569
Show file tree
Hide file tree
Showing 5 changed files with 26,615 additions and 37,189 deletions.
32 changes: 14 additions & 18 deletions __tests__/aws.test.ts
@@ -1,5 +1,5 @@
import {AuthorizationData} from '@aws-sdk/client-ecr';
import * as aws from '../src/aws';
import {AuthorizationData} from 'aws-sdk/clients/ecr';

describe('isECR', () => {
test.each([
Expand Down Expand Up @@ -55,11 +55,15 @@ describe('getAccountIDs', () => {

const mockEcrGetAuthToken = jest.fn();
const mockEcrPublicGetAuthToken = jest.fn();
jest.mock('aws-sdk', () => {
jest.mock('@aws-sdk/client-ecr', () => {
return {
ECR: jest.fn(() => ({
getAuthorizationToken: mockEcrGetAuthToken
})),
}))
};
});
jest.mock('@aws-sdk/client-ecr-public', () => {
return {
ECRPUBLIC: jest.fn(() => ({
getAuthorizationToken: mockEcrPublicGetAuthToken
}))
Expand Down Expand Up @@ -126,15 +130,11 @@ describe('getRegistriesData', () => {
const authData: AuthorizationData[] = [];
if (accountIDs.length == 0) {
mockEcrPublicGetAuthToken.mockImplementation(() => {
return {
promise() {
return Promise.resolve({
authorizationData: {
authorizationToken: Buffer.from(`AWS:world`).toString('base64'),
}
});
return Promise.resolve({
authorizationData: {
authorizationToken: Buffer.from(`AWS:world`).toString('base64'),
}
};
});
});
} else {
aws.getAccountIDs(registry).forEach(accountID => {
Expand All @@ -144,13 +144,9 @@ describe('getRegistriesData', () => {
});
});
mockEcrGetAuthToken.mockImplementation(() => {
return {
promise() {
return Promise.resolve({
authorizationData: authData
});
}
};
return Promise.resolve({
authorizationData: authData
});
});
}
const regData = await aws.getRegistriesData(registry);
Expand Down

0 comments on commit 5885569

Please sign in to comment.