2021-08-18 05:46:56 +00:00
|
|
|
import { loadFixture } from '../../../test/util';
|
2021-04-29 13:39:35 +00:00
|
|
|
import { extractPackageFile } from './extract';
|
|
|
|
|
|
|
|
const validApplication = loadFixture('validApplication.yml');
|
|
|
|
const malformedApplication = loadFixture('malformedApplications.yml');
|
|
|
|
const randomManifest = loadFixture('randomManifest.yml');
|
|
|
|
|
2021-08-18 05:46:56 +00:00
|
|
|
describe('manager/argocd/extract', () => {
|
2021-04-29 13:39:35 +00:00
|
|
|
describe('extractPackageFile()', () => {
|
|
|
|
it('returns null for empty', () => {
|
|
|
|
expect(extractPackageFile('nothing here', 'applications.yml')).toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('return null for kubernetes manifest', () => {
|
|
|
|
const result = extractPackageFile(randomManifest, 'applications.yml');
|
|
|
|
expect(result).toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('return null if deps array would be empty', () => {
|
|
|
|
const result = extractPackageFile(
|
|
|
|
malformedApplication,
|
|
|
|
'applications.yml'
|
|
|
|
);
|
|
|
|
expect(result).toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('full test', () => {
|
|
|
|
const result = extractPackageFile(validApplication, 'applications.yml');
|
|
|
|
expect(result).not.toBeNull();
|
|
|
|
expect(result.deps).toBeArrayOfSize(3);
|
|
|
|
expect(result.deps).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|