Skip to content

Unit test support #2052

@tekhedd

Description

@tekhedd

Immutable databases and automated unit tests

I'm trying Immu with the java client and a key-value adapter. Starting up and running is easy and it works.

I am having an "interesting" time making simple automated unit tests, because you can't easily clean out the database and start over. I have simple tests like:

  • parse record, verify that the expected data and only that data has been inserted.
  • Insert record that will overwrite existing key, verify that history fetching code finds it

Obviously I can't delete all the keys manually because there's also no way to iterate keys, and there will be a history of the deletion. :)

I came up with several ideas. All require logging in as the primary admin user. (Note: There is no way to add a secondary user with super-admin support from the command line, so unit tests have to run as "immudb".)

  1. Delete database and recreate. There will be a record of deletion, but that's OK I guess.

Nope. You can't delete the active, connected database. And, in the latest versions, you can't log in without connecting to an existing database. :o

  1. Create a new database (random or incrementing name) for each test

Works, but I have to have a primary database, unused, for the initial login, and be careful not to delete that. I can switch to the primary database and then delete the random-named secondary database, if necessary.

Why is this needed

Automated unit tests want to run against an empty database to simplify validation.

If there were a way to log in but be initially unconnected to any database, that would probably solve most of the problem. :)

Additional context

I'm running in Java on linux against docker instances. It all works fine aside from the missing features.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions