feat(store): add database path accessor
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
7a4997edd9
commit
5116662f41
2 changed files with 18 additions and 0 deletions
8
store.go
8
store.go
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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:",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue