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

bash_unit tests for backdating #2

Closed
masukomi opened this issue Dec 17, 2022 · 1 comment
Closed

bash_unit tests for backdating #2

masukomi opened this issue Dec 17, 2022 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@masukomi
Copy link
Owner

backdating is tricky without a good way to "freeze time"

The DB uses epoch time stamps to record time (because SQLite doesn't have a native concept of Dates or Times... at least not as far as a data type).

We need tests that confirm that starting & stopping of a task, and the creation of interruptions using the relative and absolute formats

Examples:

hey start at 4:30 @proj +task
hey stop at 5:30
hey bob at 13:50
hey bob at 1:51
hey start 4 minutes ago
hey stop 3 minutes ago

The problem is that without the ability to freeze time it becomes difficult to test the time you're expecting in the db. You have to start testing for ranges. For example, create the thing, get the current epoch time, and then test that the started_at column contains a number within 2 seconds of the current epoch time you recorded.

This is because you could create a thing, and in the millisecond between creation and reading you've crossed into the next second, and now the numbers aren't the same.

So, we a new assert function. I've filed a feature request ticket against bash_unit.

Once we have / create that then we can do the simple math of taking the current epoch time, subtracting N minutes worth of seconds, and comparing that to the backdated time shoved in the db.

@masukomi masukomi added enhancement New feature or request good first issue Good for newcomers labels Dec 17, 2022
@masukomi
Copy link
Owner Author

this has been mostly addressed with unit tests after some refactoring instead of bash_unit tests. There are bash_unit tests to sanity check that the various backdating forms don't blow up. the unit tests make sure that the actual math is right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant