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

Improve test coverage #973

Merged
merged 29 commits into from
Nov 15, 2022
Merged

Conversation

Supereg
Copy link
Member

@Supereg Supereg commented Sep 21, 2022

♻️ Current situation

Currently, a lot of parts of the HAP-NodeJS library are lacking test cases and consequentially the test coverage of the project is pretty low. This reduces our ability to catch regressions when doing changes to the code base.

💡 Proposed solution

This PR tries to improve the situation adding several test cases.

⚙️ Release Notes

  • Added several test cases for all HAP-NodeJS components

➕ Additional Information

This PR contains also slight adjustments to the code itself where it made sense or where bugs were uncovered while wiring the tests.
The PR also introduces several deprecation warnings.

The following was changed:

  • Fixed an issue where the accessory UUID id was returned in characteristic read with includeType instead of the characteristic type
  • Improved the typing of Accessory.addService
  • Fixed an issue with EventedHTTPServer and open timeout handles.
  • Fixed issues in the project structure resulting in cyclic imports
  • Added (more detailed) documentation at certain spots

Testing

Well, we added test cases for a bunch of components.

Reviewer Nudging

--

@coveralls
Copy link

coveralls commented Sep 21, 2022

Pull Request Test Coverage Report for Build 3468588397

  • 453 of 501 (90.42%) changed or added relevant lines in 17 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+13.3%) to 65.071%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/lib/util/time.ts 1 2 50.0%
src/lib/util/tlv.ts 13 14 92.86%
src/lib/Accessory.ts 55 57 96.49%
src/lib/util/promise-utils.ts 7 9 77.78%
src/lib/util/tlvError.ts 2 5 40.0%
src/lib/util/HAPHTTPError.ts 2 6 33.33%
src/lib/util/eventedhttp.ts 25 30 83.33%
src/lib/HAPServer.ts 20 35 57.14%
src/test-utils/HAPHTTPClient.ts 151 166 90.96%
Files with Coverage Reduction New Missed Lines %
src/lib/util/eventedhttp.ts 1 82.98%
Totals Coverage Status
Change from base Build 3418642106: 13.3%
Covered Lines: 7402
Relevant Lines: 10595

💛 - Coveralls

@Supereg Supereg force-pushed the feature/test-coverage-improvements branch from f7a3062 to 5d98a5d Compare October 17, 2022 05:23
@Supereg Supereg force-pushed the feature/test-coverage-improvements branch 2 times, most recently from 9193165 to 0faafca Compare November 1, 2022 15:52
@Supereg Supereg force-pushed the feature/test-coverage-improvements branch from d941bd4 to bfb665d Compare November 9, 2022 04:41
@Supereg Supereg added chore and removed feature labels Nov 9, 2022
@Supereg Supereg marked this pull request as ready for review November 15, 2022 08:10
@Supereg Supereg merged commit 6b86782 into beta-0.11.0 Nov 15, 2022
@Supereg Supereg deleted the feature/test-coverage-improvements branch November 15, 2022 08:14
Supereg added a commit that referenced this pull request Nov 18, 2022
* Add tlv test cases

* Add eventedhttp test cases

* Fix cyclic imports! Add small HAPServer test

* Add basic HAPServer negative test cases

* Add test case to verify we are sending out correct event trigger options (see #976)

* /pair-setup and pair-verify test cases

* Test that encryption keys work after pair-verify step

* Add characteristic WRITE tests

* Add RecordingManagement tests

* Adding Accessory pairing tests

* Fix spelling and improve typing of addService

* add tests for handleAccessories

* Simple characteristic read test

* Add coverage badge

* Adding characteristic write tests

* Add controller tests, add bind option tests, add characteristic warning tests

* Todo cleanup and write response tests

* Add more detailed hapCrypto layerEncrypt and layerDecrypt tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants