Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
david-wiggs committed Jul 22, 2024
1 parent 5275a08 commit 2ba839e
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/snapshot-generator.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getMavenProjectDirectory } from './utils/test-util';
import { getMavenProjectDirectory, getMavenSettingsFile } from './utils/test-util';
import { generateDependencyGraph, generateSnapshot } from './snapshot-generator';
import {describe, it, expect} from 'vitest';

Expand Down Expand Up @@ -68,5 +68,42 @@ describe('snapshot-generator', () => {
expect(snapshot.detector.version).toBe(version);
expect(snapshot.manifests['problem-dependency-graph-2602'].countDependencies()).toBe(230);
}, 40000);

it('should append correlator from snapshotConfig if it exists', async() => {
const projectDir = getMavenProjectDirectory('simple');
const mavenSettingsFile = getMavenSettingsFile();
const mavenConfig = {
ignoreMavenWrapper: true,
settingsFile: mavenSettingsFile,
mavenArgs: '-DskipTests'
};
const snapshotConfig = {
correlator: 'configCorrelator',
job: {
correlator: 'jobCorrelator'
}
};
const snapshot = await generateSnapshot(projectDir, mavenConfig, snapshotConfig);

expect(snapshot.job.correlator).toBe('jobCorrelator-configCorrelator');
}, 20000);

it('should use existing job correlator if snapshotConfig correlator does not exist', async() => {
const projectDir = getMavenProjectDirectory('simple');
const mavenSettingsFile = getMavenSettingsFile();
const mavenConfig = {
ignoreMavenWrapper: true,
settingsFile: mavenSettingsFile,
mavenArgs: '-DskipTests'
};
const snapshotConfig = {
job: {
correlator: 'jobCorrelator'
}
};
const snapshot = await generateSnapshot(projectDir, mavenConfig, snapshotConfig);

expect(snapshot.job.correlator).toBe('jobCorrelator');
}, 20000);
});
});

0 comments on commit 2ba839e

Please sign in to comment.