feat(store): add database path accessor

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-04 08:23:23 +00:00
parent 7a4997edd9
commit 5116662f41
2 changed files with 18 additions and 0 deletions

View file

@ -139,6 +139,14 @@ func (storeInstance *Store) Config() StoreConfig {
}
}
// Usage example: `databasePath := storeInstance.DatabasePath(); fmt.Println(databasePath)`
func (storeInstance *Store) DatabasePath() string {
if storeInstance == nil {
return ""
}
return storeInstance.databasePath
}
// Usage example: `storeInstance, err := store.New(":memory:", store.WithPurgeInterval(20*time.Millisecond))`
func WithPurgeInterval(interval time.Duration) StoreOption {
return func(config *StoreConfig) {

View file

@ -145,6 +145,16 @@ func TestStore_Config_Good(t *testing.T) {
}, storeInstance.Config())
}
func TestStore_DatabasePath_Good(t *testing.T) {
databasePath := testPath(t, "database-path.db")
storeInstance, err := New(databasePath)
require.NoError(t, err)
defer storeInstance.Close()
assert.Equal(t, databasePath, storeInstance.DatabasePath())
}
func TestStore_NewConfigured_Good(t *testing.T) {
storeInstance, err := NewConfigured(StoreConfig{
DatabasePath: ":memory:",