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 a few unit tests for MspHelper class #3425

Merged
merged 3 commits into from
Apr 19, 2023

Conversation

Benky
Copy link
Contributor

@Benky Benky commented Apr 18, 2023

Description

This PR adds a few unit tests for MspHelper class (more to come). Most of the data in unit tests are randomly generated, so we can test for various length / number of cases.

I've also added a few commits that simplify encode_message_v1 and handling of MSP_BOARD_INFO (for better readability and maintainability).

Notes

I can separate commits with simplification of the methods to separate PR is required.

@sonarcloud
Copy link

sonarcloud bot commented Apr 18, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@blckmn
Copy link
Member

blckmn commented Apr 18, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> PASS
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> PASS
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> PASS
  • Tested label found -> PASS
  • assigned to an approver -> FAIL
  • approver count at least three -> FAIL

@nerdCopter
Copy link
Member

$ yarn test
yarn run v1.22.19
$ yarn run lint
$ eslint --ext .js,.vue src gulpfile.js gulp-appdmg.js
$ vitest

 DEV  v0.27.1 /media/disk2/SYNC/nerdCopter-GIT/betaflight-configurator

stderr | unknown test
NO Clipboard available

stderr | test/js/msp/MSPHelper.test.js > MspHelper > process_data > refuses to process data with crc-error
code: 4 (MSP_BOARD_INFO) - crc failed

 ✓ test/js/msp.test.js (4) 595ms
 ✓ test/js/msp/MSPHelper.test.js (5)
 ✓ test/tabs/cli.test.js (13)

 Test Files  3 passed (3)
      Tests  22 passed (22)
   Start at  14:12:31
   Duration  2.34s (transform 970ms, setup 360ms, collect 1.37s, tests 678ms)

flashed one FC; pseudo-configured without any known issue. (unsoldered)

@haslinghuis haslinghuis merged commit 1657351 into betaflight:master Apr 19, 2023
@haslinghuis
Copy link
Member

haslinghuis commented Apr 19, 2023

@Benky is this is false positive? Noticed while working on another PR and see it's in the above test also.

stderr | test/js/msp/MSPHelper.test.js > MspHelper > process_data > refuses to process data with crc-error
code: 4 (MSP_BOARD_INFO) - crc failed

@Benky
Copy link
Contributor Author

Benky commented Apr 24, 2023

Hey @haslinghuis - first of all, sorry for late response.

It's actually an expected thing - it's generated by https://github.com/betaflight/betaflight-configurator/blob/master/src/js/msp/MSPHelper.js#L1645 which gets triggered during this test :

it("refuses to process data with crc-error", () => {
which actually tests handling of messages with failed CRC checksums. So us seeing that message there is inevitable, as it's generated by the code (and branches) we're trying to test in that unit test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

4 participants