Add tests for adding a conflicting edge (#366)

Adding a conflicting edge (i.e. one with the same address, but different
`src` or `dst`) is an error. However, our coverage has determined that
the behavior isn't tested. This commit adds that test.

Test plan:
Only change is adding a new test. Verify `yarn travis` passes.
This commit is contained in:
Dandelion Mané 2018-06-08 12:30:50 -07:00 committed by GitHub
parent d90cd3cf1b
commit b8298123ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -165,6 +165,21 @@ describe("core/graph", () => {
}); });
}); });
it("throws on conflicting edge", () => {
const src = NodeAddress.fromParts(["src"]);
const dst = NodeAddress.fromParts(["dst"]);
const address = EdgeAddress.fromParts(["hi"]);
const e1 = {src, dst, address};
const e2 = {src, dst: src, address};
const graph = new Graph()
.addNode(src)
.addNode(dst)
.addEdge(e1);
expect(() => graph.addEdge(e2)).toThrow(
"conflict between new edge"
);
});
describe("throws on edge with", () => { describe("throws on edge with", () => {
const n = NodeAddress.fromParts(["foo"]); const n = NodeAddress.fromParts(["foo"]);
const e = EdgeAddress.fromParts(["bar"]); const e = EdgeAddress.fromParts(["bar"]);