embedded-postgres
libsqlfs
embedded-postgres | libsqlfs | |
---|---|---|
5 | 10 | |
326 | 582 | |
2.5% | 1.9% | |
6.4 | 0.0 | |
about 1 month ago | 7 months ago | |
Java | C | |
Apache License 2.0 | GNU Lesser General Public License v3.0 only |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
embedded-postgres
- Testcontainers
-
Why you should probably be using SQLite
Little use if you’re not on the JVM but I’ve had great success with Embedded Postgres:
https://github.com/zonkyio/embedded-postgres
Each test just copies a template database so it’s ultra fast and avoids the need for complicated reset logic.
-
Ask HN: What's your favorite software testing framework and why?
Outside of differences between assertion-based unit tests and property-based tests (both of which are worth doing), I don't think framework makes much difference. But your approach to testing definitely does.
I think every language having its own testing framework is good, even for things like functional tests which can often be externalised. Tests are an essential part of every project and should be well integrated with the rest of the codebase and the team creating it. Often, the tests are the only good place to go and see what an app actually _does_ and so they form an essential part of the documentation.
In my experience it's very rare that you can effectively create and maintain something like Cucumber tests owned by anyone but the team implementing the code so there's little benefit to translating from a text DSL like that. But the language used is definitely useful, so what I like to see is code in the implementation language that matches the Given/When/Then structure of those tests, but instead of reusable text steps you just have reusable functions which take parameters. This means you can easily refactor, and use the full functionality of your IDE to suggest and go to definitions etc. No matter what, you should treat your test code the same way you do everything else - abstractions matter, so functional tests at the top level should rarely just be about clicking on things and asserting other things, they should be in the language of the domain.
Functional tests are worth much more than unit tests. No only do they test the only things of actual business value, they are also more robust in the face of implementation refactorings and so require less rework (unless you're being overly specific with CSS selectors etc). Unit tests are often highly coupled to specific implementations and can be a poor investment, especially early in a project. I believe a good balance is functional and integration tests that explore the various paths through your app and prove everything's hooked up, coupled with property based unit tests for gnarly or repetitive logic that isn't worth endlessly iterating via the UI. All other unit tests are optional and at the discretion of the implementer.
You should be able to mock out every major articulation point in your code, but it's generally preferable if you can mock _real_ dependencies. That is, instead of mocking out a 'repository' abstraction that looks stuff up and returns canned data, have a real test database against which you look up real data (created by steps in your functional tests). This reduces risk and cognitive overhead (you're not having to encode too many assumptions in your test suite) and doesn't have to be as slow as people like to make out - Embedded Postgres is quite fast, for example:
https://github.com/zonkyio/embedded-postgres
Same with network services - it's not slow to chat to localhost and you'll find more issues testing proper round-trips. I have not found "assert that you called X" style testing with mocks useful - you care about outcomes, not implementation details.
Beyond all that, as long as you can make assertions that generate clear error messages, you're fine.
-
Hctree is an experimental high-concurrency database back end for SQLite
I use an embedded postgres testing library for the JVM that does something along those lines.
Well no actually it just unpacks the tar file in a temp dir and runs the full postgres, but it mostly feels like what you describe (minus the single file part) and starts surprisingly fast. That would totally work for a little proof of concept (https://github.com/zonkyio/embedded-postgres)
- Thoughts on Micronaut vs. Quarkus?
libsqlfs
-
The File Filesystem
Closest I found: https://github.com/guardianproject/libsqlfs
> The libsqlfs library implements a POSIX style file system on top of an SQLite database. It allows applications to have access to a full read/write file system in a single file, complete with its own file hierarchy and name space. This is useful for applications which needs structured storage, such as embedding documents within documents, or management of configuration data or preferences. Libsqlfs can be used as an shared library, or it can be built as a FUSE (Linux File System in User Space) module to allow a libsqlfs database to be accessed via OS level file system interfaces by normal applications.
-
Why you should probably be using SQLite
- Use clone file to duplicate the cached data directory to give to individual tests.
One thing I'd like to pursue is to store the Postgres data dir in SQLite [1]. Then, I can reset the "file system" using SQL after each test instead of copying the entire datadir.
[1]: https://github.com/guardianproject/libsqlfs
-
SQLite: 35% Faster Than the Filesystem
Not sure about compression but somebody could probably hack it in an afternoon using this:
https://github.com/guardianproject/libsqlfs
or something similar to check the potential for speed up.
- Libsqlfs: A Posix-style file system on top of an SQLite database
- FUSE based Posix style file system on top of an SQLite database
-
Why the Windows Registry sucks technically (2010)
Maybe there isn't a database engine that explicitly supports file system daya structures, but you could implement a filesystem in the application layer using SQLite as a storage mechanism.
Here's an example of someone doing that very thing.
https://github.com/guardianproject/libsqlfs
- Is it time to remove reiserfs?
- SQLite Archive Files
-
A Future for SQL on the Web
now let's see what it takes to make absurd-fs, where we use https://github.com/guardianproject/libsqlfs to make a filesystem on top of sqlite on top of the File System Access API.
gotta keep ourselves fully looped. ⥀
What are some alternatives?
greenlight - Clojure integration testing framework
sqlite-zstd - Transparent dictionary-based row-level compression for SQLite
postgresql-embedded - Embedded PostgreSQL Server
sqlitefs - sqlite as a filesystem
testy - test helpers for more meaningful, readable, and fluent tests
dirs-rs - a low-level library that provides config/cache/data paths, following the respective conventions on Linux, macOS and Windows
php-easycheck - Mirror of http://chriswarbo.net/git/php-easycheck
StorX - PHP library for flat-file data storage
ospec - Noiseless testing framework
sqlfs - Sqlite FUSE filesystem with sqlcipher support
datadriven - Data-Driven Testing for Go
nix-1p - A (more or less) one page introduction to Nix, the language.