fix(graph): report a self-dependency as the cycle it is (GitHub #43)
A node that needs the token it provides is a cycle of one, so say so in the same words as every other cycle (`cycle detected: a -> a`), and name the token and the fix: cycle detected: auth -> auth (it needs 'user', which only it provides). Remove 'user' from its needs, or move the work that produces 'user' into a step it needs. "missing dependency … it provides it itself" pointed the reader at a missing producer, when the producer is there and the problem is the loop. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
4 files changed
+14
-9
No files matched your search
+1
-1
@@ -57,7 +57,7 @@ describe('one producer per token', () => {
|
||||
describe('self-dependency', () => {
|
||||
it('counts as missing when the token is not seeded', () => {
|
||||
expect(() => topoSort([node('auth', ['user'], ['user'])], [])).toThrow(
|
||||
/missing dependency: user needed by auth — it provides 'user' itself/,
|
||||
/cycle detected: auth -> auth \(it needs 'user', which only it provides\)/,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -88,9 +88,9 @@ describe('one producer per token', () => {
|
||||
// check that rejects the node runs before any override could.
|
||||
it('a node that needs the token it provides fails boot, with or without an override', () => {
|
||||
const loop = adds('loop', { kind: 'step', name: 'loop', needs: ['loop'], provides: ['loop'] });
|
||||
expect(() => createApp({ modules: [AppModule], plugins: [loop] })).toThrow(/missing dependency: loop needed by loop/);
|
||||
expect(() => createApp({ modules: [AppModule], plugins: [loop] })).toThrow(/cycle detected: loop -> loop/);
|
||||
expect(() => createApp({ modules: [AppModule], plugins: [loop], overrides: { loop: 1 } })).toThrow(
|
||||
/missing dependency: loop needed by loop/,
|
||||
/cycle detected: loop -> loop/,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user