Skip to content

Commit

Permalink
Refactor tests and add churn, complexity metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
alec-chernicki committed Jul 10, 2024
1 parent e1b53e0 commit d7e1292
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 96 deletions.
52 changes: 26 additions & 26 deletions packages/data-constraints/src/get-constraint-results.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand All @@ -263,7 +263,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -304,7 +304,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand All @@ -320,7 +320,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -361,7 +361,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -408,7 +408,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand All @@ -424,7 +424,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-c',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -465,7 +465,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -524,19 +524,19 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
{
source: 'pkg-b',
target: 'pkg-c',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
{
source: 'pkg-c',
target: 'pkg-d',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand All @@ -553,19 +553,19 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'development',
type: DependencyType.DEVELOPMENT,
version: '1.0.0',
},
{
source: 'pkg-b',
target: 'pkg-c',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
{
source: 'pkg-c',
target: 'pkg-d',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -605,7 +605,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -645,7 +645,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -685,7 +685,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-a',
target: 'pkg-b',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down Expand Up @@ -774,7 +774,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-one',
target: 'pkg-two',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand All @@ -790,7 +790,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-one',
target: 'pkg-three',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand All @@ -806,7 +806,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-one',
target: 'pkg-four',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand All @@ -822,7 +822,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-four',
target: 'pkg-six',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand All @@ -838,7 +838,7 @@ describe('get-constraint-results', () => {
{
source: 'pkg-three',
target: 'pkg-one',
type: 'production',
type: DependencyType.PRODUCTION,
version: '1.0.0',
},
],
Expand Down
2 changes: 2 additions & 0 deletions packages/data-packages/src/get-package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ describe('getPackage', () => {
path: 'packages/pkg-one',
type: PackageType.NODE,
version: '1.0.0',
churn: 0.3,
complexity: 0.3,
});
});
});
6 changes: 6 additions & 0 deletions packages/data-packages/src/get-packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe('getPackages', () => {
description: 'root description',
path: '.',
type: PackageType.NODE,
churn: 0.3,
complexity: 0.3,
},
]);
});
Expand All @@ -41,13 +43,17 @@ describe('getPackages', () => {
description: 'pkg-one description',
path: 'packages/pkg-one',
type: PackageType.NODE,
churn: 0.3,
complexity: 0.3,
},
{
name: 'pkg-two',
version: '1.0.0',
description: 'pkg-two description',
path: 'packages/pkg-two',
type: PackageType.NODE,
churn: 0.3,
complexity: 0.3,
},
]);
});
Expand Down
9 changes: 7 additions & 2 deletions packages/data-tags/test/set-tags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import { fileURLToPath } from 'node:url';
import { PackageType } from '@commonalityco/utils-core';

describe('setTags', () => {
const temporaryDirectoryPath = path.join(
process.env['RUNNER_TEMP'] || os.tmpdir(),
'set-tags-',
);

describe('when setting tags for a package with no configuration file', () => {
const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir();
const temporaryPath = mkdtempSync(temporaryDirectoryPath);
const emptyFixturePath = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
Expand Down Expand Up @@ -50,6 +54,8 @@ describe('setTags', () => {
path: './packages/pkg-one',
type: PackageType.NEXT,
version: '1.0.0',
churn: 0.5,
complexity: 0.5,
},
tags: ['tag-one'],
});
Expand All @@ -61,7 +67,6 @@ describe('setTags', () => {
});

describe('when setting tags for a package with existing tags', () => {
const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir();
const temporaryPath = mkdtempSync(temporaryDirectoryPath);
const fixturePath = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
Expand Down
4 changes: 2 additions & 2 deletions packages/utils-conformance/src/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ describe('diff', () => {

expect(result).toMatchInlineSnapshot(`
" Object {
\\"name\\": \\"pkg-a\\",
+ \\"name\\": \\"pkg-b\\",
"name": "pkg-a",
+ "name": "pkg-b",
}"
`);
});
Expand Down
Loading

0 comments on commit d7e1292

Please sign in to comment.