Skip to content

Developer Guide

This site is under construction.


Testing is essential for delivering good and reliable software. PushBits uses Go's integrated test features. Unfortunately, writing tests is quite time consuming and therefore not every feature and every line of code is automatically tested. Feel free to help us improve our tests.

To run tests for a single (sub)module you can simply execute the following command in the module's folder.

go test

To get the testing coverage for a module use the -cover flag.

go test -cover

To execute a single test use the -run flag.

go test -run "TestApi_getUser"

Running tests for all PushBits module is done like this:

make test

Testing the Alertmanager interface

Setting up a local Alertmanager instance is done quickly using Docker or Podman. We first create the file config.yml that tells Alertmanger where to send alerts. Don't forget to replace <PB_TOKEN> with your application's token.

  receiver: default

  - name: default
      - url: http://localhost:8080/alert?token=<PB_TOKEN> # Replace <PB_TOKEN> with your application's token.

We mount this file into a container running Alertmanager. For convenience, let's use this Makefile:

CONTAINER_NAME := alertmanager

.PHONY: up
    podman run --name $(CONTAINER_NAME) --rm --network host -v $(PWD)/config.yml:/etc/alertmanager/alertmanager.yml:Z $(IMAGE_NAME)

.PHONY: down
    podman container stop $(CONTAINER_NAME)

.PHONY: send
    amtool alert add alertname=testmessage --annotation=title='My Title' --annotation=message='My Message'

.PHONY: setup
    go install

So first you would install the client using make setup, followed by starting Alertmanager with make up. When PushBits is running, a make send would create a new alert in Alertmanager, which is then passed to PushBits via the defined webhook.