Skip to content

Commit

Permalink
test(report): adds support for 'circular' type rules in the azure-dev…
Browse files Browse the repository at this point in the history
…ops reporter
  • Loading branch information
sverweij committed Jul 8, 2023
1 parent f50b10e commit 360371d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
8 changes: 7 additions & 1 deletion src/report/azure-devops.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ function formatDependencyViolation(pViolation) {
return `${pViolation.rule.name}: ${pViolation.from} -> ${pViolation.to}`;
}

function formatCycleViolation(pViolation) {
return `${pViolation.rule.name}: ${
pViolation.from
} -> ${pViolation.cycle.join(" -> ")}`;
}

/**
*
* @param {import("../../types/violations.js").IViolation} pViolation
Expand All @@ -42,7 +48,7 @@ function formatViolation(pViolation) {
const lViolationType2Formatter = {
module: formatModuleViolation,
dependency: formatDependencyViolation,
// cycle: formatCycleViolation,
cycle: formatCycleViolation,
// reachability: formatReachabilityViolation,
// instability: formatInstabilityViolation,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
##vso[task.logissue type=error;sourcepath=src/some/folder/nested/center.js]no-circular: src/some/folder/nested/center.js -> src/some/folder/loop-a.js -> src/some/folder/loop-b.js -> src/some/folder/nested/center.js
##vso[task.logissue type=error;sourcepath=src/some/folder/loop-a.js]no-circular: src/some/folder/loop-a.js -> src/some/folder/loop-b.js -> src/some/folder/nested/center.js -> src/some/folder/loop-a.js
##vso[task.logissue type=error;sourcepath=src/some/folder/loop-b.js]no-circular: src/some/folder/loop-b.js -> src/some/folder/nested/center.js -> src/some/folder/loop-a.js -> src/some/folder/loop-b.js
##vso[task.complete result=Failed;]3 dependency violations (3 error, 0 warning/ informational). 3 modules, 3 dependencies cruised
22 changes: 12 additions & 10 deletions test/report/azure-devops/azure-devops.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import warndeps from "./__mocks__/there-are-warnings.mjs";
import errdeps from "./__mocks__/there-are-errors.mjs";
import moduleErrs from "./__mocks__/module-errors.mjs";
import requiredErrs from "./__mocks__/required-errors.mjs";
// import circulars from "./__mocks__/circular-deps.mjs";
import circulars from "./__mocks__/circular-deps.mjs";
// import vias from "./__mocks__/via-deps.mjs";
// import unsupportedErrorLevels from "./__mocks__/unsupported-severity.mjs";
// import knownViolations from "./__mocks__/known-violations.mjs";
Expand Down Expand Up @@ -81,16 +81,18 @@ describe("[I] report/azure-devops", () => {
expect(lResult.exitCode).to.equal(5);
});

// it("renders circular transgressions", () => {
// const lFixture = readFixture(
// "__mocks__/circular-deps-azure-devops-format.txt"
// );
// const lResult = render(circulars);
it("renders circular transgressions", () => {
const lFixture = readFixture(
"__mocks__/circular-deps-azure-devops-format.txt"
);
const lResult = render(circulars);

// expect(lResult.output).to.equal(lFixture);
// // eslint-disable-next-line no-magic-numbers
// expect(lResult.exitCode).to.equal(3);
// });
expect(normalizeNewline(lResult.output)).to.equal(
normalizeNewline(lFixture)
);
// eslint-disable-next-line no-magic-numbers
expect(lResult.exitCode).to.equal(3);
});

// it("renders via transgressions", () => {
// const lFixture = readFixture("__mocks__/via-deps-azure-devops-format.txt");
Expand Down

0 comments on commit 360371d

Please sign in to comment.