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

Extend unit test for existing functions #23

Merged
merged 2 commits into from
Jun 16, 2021

Conversation

sofiasyria
Copy link
Contributor

@sofiasyria sofiasyria commented Dec 31, 2020

Adding functions to unit test

OneClickInstall:
GetRequiredRepositories
GetNonRequiredRepositories
SetNonRequiredRepository
SetRequiredRepositories
GetRequiredSoftware
GetRequiredPackages
GetRequiredPatterns
GetRequiredRemoveSoftware
HaveAnyRecommended
Load
makeXMLFriendly
fromXMLFriendly
ToXML
FromXML

OneClickInstallWorkerFunctions:
InstallPackages
InstallPatterns
RemovePackages

spec/OneClickInstall_spec.rb Outdated Show resolved Hide resolved
spec/OneClickInstall_spec.rb Outdated Show resolved Hide resolved
spec/OneClickInstall_spec.rb Outdated Show resolved Hide resolved
spec/OneClickInstall_spec.rb Outdated Show resolved Hide resolved
spec/OneClickInstall_spec.rb Outdated Show resolved Hide resolved
spec/OneClickInstall_spec.rb Outdated Show resolved Hide resolved
spec/OneClickInstall_spec.rb Outdated Show resolved Hide resolved
@jknphy
Copy link

jknphy commented Jan 4, 2021

For the commit and first message I would recommend something like: "Add unit tests for existing functions" or "Extend unit test coverage: (non)required repos/sw/pkgs" or something like that.

@sofiasyria sofiasyria changed the title Add more functions to unit test Extend unit test for existing functions Jan 4, 2021
@sofiasyria sofiasyria force-pushed the unit_test branch 3 times, most recently from f59de3b to 4473781 Compare January 5, 2021 15:55
spec/OneClickInstall_spec.rb Outdated Show resolved Hide resolved
spec/OneClickInstall_spec.rb Outdated Show resolved Hide resolved
@jknphy
Copy link

jknphy commented Jan 6, 2021

LGTM, just those minor things that YaST developers will know better :)

@sofiasyria
Copy link
Contributor Author

@mvidner @jreidinger if you have some time, kindly review.

@coveralls
Copy link

coveralls commented Jun 14, 2021

Pull Request Test Coverage Report for Build 938911081

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+8.1%) to 20.646%

Totals Coverage Status
Change from base Build 857355965: 8.1%
Covered Lines: 422
Relevant Lines: 2044

💛 - Coveralls

filename = File.join(DATA_PATH, "serialized_result.xml")
subject.ToXML(filename)
expected = File.join(DATA_PATH, "serialized_expected.xml")
expect(IO.read(filename)).to eql(IO.read(expected))
Copy link
Member

Choose a reason for hiding this comment

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

Just note that can be quite fragile as identical XML is not necessary same as same content of xml due to formatting. Maybe comparing parsed xml trees is better way?

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 tried to replace it with expect(REXML::Document.new(filename)).to eq(REXML::Document.new(expected)) but doesn't work. What did you have in mind?

Copy link
Contributor Author

@sofiasyria sofiasyria Jun 15, 2021

Choose a reason for hiding this comment

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

In the end, I used file.read and it worked but still not using the xml tree. Another option would be to check the result partially like:
expect(file).to include("key").exactly(12).times
software.each_key{|key| expect(file).to include(key)}
repositories.each_key{|key| expect(file).to include(key)}

Copy link
Member

Choose a reason for hiding this comment

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

looks like it is not so easy. I found this https://stackoverflow.com/questions/30088334/compare-rexml-elements-for-name-attribute-equality-in-rspec so probably not worth it.

GetRequiredRepositories
GetNonRequiredRepositories
SetNonRequiredRepository
SetRequiredRepositories
GetRequiredSoftware
GetRequiredPackages
GetRequiredPatterns
GetRequiredRemoveSoftware
HaveAnyRecommended
Load
makeXMLFriendly
fromXMLFriendly
ToXML
FromXML
InstallPackages
InstallPatterns
RemovePackages
@jreidinger jreidinger merged commit 3d853e2 into yast:master Jun 16, 2021
@yast-bot
Copy link
Contributor

✔️ Public Jenkins job #16 successfully finished

@yast-bot
Copy link
Contributor

✔️ Internal Jenkins job #7 successfully finished
✔️ Created IBS submit request #243693

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.

5 participants