Adds tests for Common/Types/Database #1501

Closed
opened 2026-04-05 16:27:50 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @koox00 on 11/15/2023

Adds tests for Common/Types/Database.

Adds new tests for some of the files in Common/Types/Database directory.
Refactored one test (ColumnLength) to increase test coverage and simplicity.

Upon writing the tests I noticed a couple of issues.

  1. IsPermissionsIf decorator didn't seem to set the property due to the initial property value in the BaseModel, at least upon testing. Moved the initialization to the constructor and to set only if there isn't a value, to fix this.
  2. Classes that extend CompareBase, AKA classes that take either a number or a Date as value, "fail" serialization and de-serialization. The value in the end object ends up a string. This commit attempts to fix that as well.

PS: I used Date.toJSON() as it is the method that JSON.stringify would call on a date.

Pull Request Checklist:

  • Please make sure all jobs pass before requesting a review.
  • Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).
  • Have you lint your code locally before submission?
  • Did you write tests where appropriate?

#210

*Originally created by @koox00 on 11/15/2023* ### Adds tests for Common/Types/Database. Adds new tests for some of the files in `Common/Types/Database` directory. Refactored one test (`ColumnLength`) to increase test coverage and simplicity. Upon writing the tests I noticed a couple of issues. 1. `IsPermissionsIf` decorator didn't seem to set the property due to the initial property value in the `BaseModel`, at least upon testing. Moved the initialization to the constructor and to set only if there isn't a value, to fix this. 2. Classes that extend `CompareBase`, AKA classes that take either a number or a Date as value, "fail" serialization and de-serialization. The value in the end object ends up a `string`. This commit attempts to fix that as well. PS: I used `Date.toJSON()` as it is the method that `JSON.stringify` would call on a date. ### Pull Request Checklist: - [x] Please make sure all jobs pass before requesting a review. - [ ] Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). - [x] Have you lint your code locally before submission? - [x] Did you write tests where appropriate? ### Related Issue #210
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#1501