chore: this should work (famous last words)

Signed-off-by: blam <ben@blam.sh>

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-08-19 16:26:55 +02:00
parent 1de5594c75
commit b27099595f
5 changed files with 178 additions and 106 deletions
@@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mockAws from 'aws-sdk-mock';
import aws from 'aws-sdk';
import path from 'path';
import { getVoidLogger, UrlReaders } from '@backstage/backend-common';
import { ConfigReader } from '@backstage/config';
import { AwsS3DiscoveryProcessor } from './AwsS3DiscoveryProcessor';
@@ -22,12 +24,8 @@ import {
CatalogProcessorResult,
processingResult,
} from '@backstage/plugin-catalog-backend';
import AWSMock from 'aws-sdk-mock';
import aws from 'aws-sdk';
import path from 'path';
import YAML from 'yaml';
AWSMock.setSDKInstance(aws);
const object: aws.S3.Types.Object = {
Key: 'awsS3-mock-object.txt',
};
@@ -35,8 +33,11 @@ const objectList: aws.S3.ObjectList = [object];
const output: aws.S3.Types.ListObjectsV2Output = {
Contents: objectList,
};
AWSMock.mock('S3', 'listObjectsV2', output);
AWSMock.mock(
mockAws.setSDKInstance(require('aws-sdk'));
mockAws.mock('S3', 'listObjectsV2', output);
mockAws.mock(
'S3',
'getObject',
Buffer.from(
@@ -75,6 +76,7 @@ describe('readLocation', () => {
},
),
)) as CatalogProcessorEntityResult;
console.log(generated);
expect(generated.type).toBe('entity');
expect(generated.location).toEqual({
target: 'awsS3-mock-object.txt',