pushbits / server

A simple server for push notifications via Matrix (and a minimalistic alternative to Pushover and Gotify) 🚀📯
https://www.pushbits.io
ISC License
314 stars 18 forks source link

Add testing to PushBits #32

Closed CubicrootXYZ closed 3 years ago

CubicrootXYZ commented 3 years ago

I added a few tests, let's discuss if this is the approach we want to use.

I tried to make the tests as lightweight as possible - without any fancy testing suites or so. A description on how to use them is appended to the Readme.

The new "tests" module holds helpers for initializing tests.

CubicrootXYZ commented 3 years ago

Well, one part I did not think about is the automatic testing in the action. It will not work as there is no config.yml provided with e.g. matrix credentials. Should we just skip those tests when no config is provided or do we want to somehow get those credentials into the action?

eikendev commented 3 years ago

This is related to #12.

eikendev commented 3 years ago

Hey @CubicrootXYZ, thanks for this pull request!

I think unit tests make the most sense for now; great idea to have a separate mockup module.

As for your question: I'm not yet certain what tests fail exactly. Either way, I would "assume" the library to function properly, so we only need to test what calls are made. Maybe we can setup the tests in a way so the function calls are actually made to a module of our own instead to the library? That way, we would just "emulate" a connection and check if correct calls were made. What I would refrain from is having credentials used in the tests: it's best to be able to perform the tests without Internet connection anyway.

CubicrootXYZ commented 3 years ago

Only part that needed credentials was the dispatcher - replaced him with a generic one that does nothing. Now the tests run without any external information needed.

CubicrootXYZ commented 3 years ago

Looking good! Is this ready to merge?

Yes :)