spacepy / dbprocessing

Automated processing controller for heliophysics data
5 stars 4 forks source link

Create "empty" test database in unit tests #113

Closed jtniehof closed 2 years ago

jtniehof commented 2 years ago

To date, the unit tests proceed mostly by working on a "reference" sqlite database checked into the repository. One of these is "empty", i.e. contains only the dbprocessing table structure but no data.

This PR removes the checked-in empty database. All tests which use an empty database now create the database structure on the fly at the beginning of the test and destroy it at the end.

This PR also checks for PGDATABASE. If it is set, the empty database tests work on an empty Postgresl database instead of sqlite. The database itself must exist, but not the tables. Other tests continue to use sqlite (this is a task for the future). Because of this, a few test failures in Postgresql were also fixed. Only about 20 of the unit tests work on the empty database, but it's a start.

There was some special handling for Postgres testing in the CI suite; that's gone now. The only difference is the setting of the environment variable.

A note on performance: Obviously all this setup/teardown takes some time. Comparison of timing, for running the entire test suite:

So there isn't much of a performance penalty for tests we already had, and the "slow" bit is brand-new tests of the Postgres functionality, which may just plain have more overhead anyhow.

PR Checklist

At this point I'm not putting something in release notes because it isn't a substantial improvement in Postgres support, but it's a step towards #14. I want to get this in the bag before converting the rest of the tests. (Also make sure the CI works properly.)