Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added get graph command #408

Merged
merged 1 commit into from
Dec 4, 2018
Merged

feat: added get graph command #408

merged 1 commit into from
Dec 4, 2018

Conversation

thsig
Copy link
Collaborator

@thsig thsig commented Dec 3, 2018

This command returns a serialized representation of the project's
DependencyGraph.

@edvald
Copy link
Collaborator

edvald commented Dec 3, 2018

LGTM. @eysi09 any thoughts?

opts: {},
})

expect(Object.keys(res.result!).sort()).to.eql(["nodes", "relationships"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a sort here? the order should be predictable right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the sort is unnecessary, but I find the key ordering guarantee a bit vague:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#Examples

So I've always assumed I had to ensure the key order myself when using Object.keys.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is if the function should return a predictable list, then the function should do the sorting not the tests... it hides hidden logic around ordering. (in this test it doesn't matter)

I can see that you are actually trying to get the keys out of the "object" but I guess we should be explicitly checking that the 2 objects are equal?

This test doesn't feel like it tests a valid expected result?

There is a bunch of logic in the dependency-graph.ts that does filtering / sorting but never actually tests tested?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a stable topological sorting algorithm (didn't find a JS lib that implemented one of those), testing the ordering means essentially re-implementing the logic in the test, so I'm skipping that for now (added a TODO comment about this).

I think we should just merge this one for now.

@thsig thsig force-pushed the get-graph-command branch from 15c4592 to 9513b65 Compare December 4, 2018 12:03
This command returns a serialized representation of the project's
DependencyGraph.
@edvald edvald force-pushed the get-graph-command branch from 9513b65 to 010353e Compare December 4, 2018 13:47
@edvald edvald merged commit d46341d into master Dec 4, 2018
@edvald edvald deleted the get-graph-command branch December 4, 2018 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants