Testing

Tester source code.

Tests are run automatically by Travis when a new commit is pushed to project’s github repo.

Testing is implemented by using the standard Go testing facilities to first initialize the testing by building and running zab2.go and connecting it and Habbix to a special test database, which is reset by Travis from a db dump before running the tests, and then sending a bunch of http queries to the server. Tests check if the received data matches the expected values (specified in various test slices [slice = kinda-array in Go]) before and after the test database is updated . Specifically:

Configuring test data is simple if a bit cumbersome, since it’s basically just copy pasting “good” values from correctly returned data (mostly JSON, some html) to various test slices (slice = kinda-array in go).

If multi-axis database receives some structural upgrades or new models need testing, the database dump the tests use should probably be updated. After that, some test data (certainly forecast data) must be reconfigured by hand, which is of course a pain.

Important issues

Because of some problems with running Habbix in some systems, currently TestPostUpdateForecast and TestPostUpdateDashboard do not actually test anything. When these issues are resolved, expected post-update forecast data should be updated to the new fields of forecasttests. Similar changes are necessary in dashboardtests struct.