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

Add tests for libfetchers/attrs.hh #3703

Closed
wants to merge 1 commit into from

Conversation

gilligan
Copy link
Contributor

Add tests for the json/attr functions


it = attrs.find("bool");
ASSERT_NE(it, attrs.end());
//ASSERT_EQ(std::get<Explicit<bool>>(it->second).t, true); // unexpected index exception
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could use some help with this. I really don't understand what's going on here and why i am failing to get the bool value out of there

std::map<std::string, std::string> expected = {
{ "num", "42" },
{ "string", "this is a string" },
{ "bool", "1" }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do wonder why the boolean is being converted to "1" or "0" here instead of true or false..

Copy link
Member

Choose a reason for hiding this comment

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

IIRC this is fixed on the flakes branch, which rewrites most of libfetchers. Please rebase on that branch. BTW, that's an example of the cost of unit tests: you end up writing a lot of code that has to be discarded when the API changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, that's an example of the cost of unit tests: you end up writing a lot of code that has to be discarded when the API changes.

I think Nix might be the only current project that I know where unit tests are regarded a controversial topic.

The way everyone else seems to look at it is that unit tests are a net win because they provide confidence when making changes and thus effectively making API changes easier and safer.

Add tests for the json/attr functions
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.

None yet

2 participants