Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/store/RFC.md fully. Find ONE featur...' (#100) from agent/read---spec-code-core-go-store-rfc-md-fu into dev
This commit is contained in:
commit
7a571f1958
2 changed files with 22 additions and 0 deletions
12
store.go
12
store.go
|
|
@ -147,6 +147,18 @@ func (storeInstance *Store) DatabasePath() string {
|
|||
return storeInstance.databasePath
|
||||
}
|
||||
|
||||
// Usage example: `if storeInstance.IsClosed() { return }`
|
||||
func (storeInstance *Store) IsClosed() bool {
|
||||
if storeInstance == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
storeInstance.closeLock.Lock()
|
||||
closed := storeInstance.closed
|
||||
storeInstance.closeLock.Unlock()
|
||||
return closed
|
||||
}
|
||||
|
||||
// Usage example: `storeInstance, err := store.New(":memory:", store.WithPurgeInterval(20*time.Millisecond))`
|
||||
func WithPurgeInterval(interval time.Duration) StoreOption {
|
||||
return func(config *StoreConfig) {
|
||||
|
|
|
|||
|
|
@ -155,6 +155,16 @@ func TestStore_DatabasePath_Good(t *testing.T) {
|
|||
assert.Equal(t, databasePath, storeInstance.DatabasePath())
|
||||
}
|
||||
|
||||
func TestStore_IsClosed_Good(t *testing.T) {
|
||||
storeInstance, err := New(":memory:")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.False(t, storeInstance.IsClosed())
|
||||
require.NoError(t, storeInstance.Close())
|
||||
assert.True(t, storeInstance.IsClosed())
|
||||
assert.True(t, (*Store)(nil).IsClosed())
|
||||
}
|
||||
|
||||
func TestStore_NewConfigured_Good(t *testing.T) {
|
||||
storeInstance, err := NewConfigured(StoreConfig{
|
||||
DatabasePath: ":memory:",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue