[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/store/RFC.md fully. Find features d... #130
2 changed files with 19 additions and 0 deletions
7
store.go
7
store.go
|
|
@ -45,6 +45,13 @@ type StoreConfig struct {
|
|||
|
||||
// Usage example: `if err := (store.StoreConfig{DatabasePath: ":memory:", PurgeInterval: 30 * time.Second}).Validate(); err != nil { return }`
|
||||
func (config StoreConfig) Validate() error {
|
||||
if config.DatabasePath == "" {
|
||||
return core.E(
|
||||
"store.StoreConfig.Validate",
|
||||
"database path is empty",
|
||||
nil,
|
||||
)
|
||||
}
|
||||
if config.Journal != (JournalConfiguration{}) && !config.Journal.isConfigured() {
|
||||
return core.E(
|
||||
"store.StoreConfig.Validate",
|
||||
|
|
|
|||
|
|
@ -170,6 +170,12 @@ func TestStore_StoreConfig_Bad_NegativePurgeInterval(t *testing.T) {
|
|||
assert.Contains(t, err.Error(), "purge interval must be zero or positive")
|
||||
}
|
||||
|
||||
func TestStore_StoreConfig_Bad_EmptyDatabasePath(t *testing.T) {
|
||||
err := (StoreConfig{}).Validate()
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "database path is empty")
|
||||
}
|
||||
|
||||
func TestStore_NewConfigured_Bad_NegativePurgeInterval(t *testing.T) {
|
||||
_, err := NewConfigured(StoreConfig{
|
||||
DatabasePath: ":memory:",
|
||||
|
|
@ -180,6 +186,12 @@ func TestStore_NewConfigured_Bad_NegativePurgeInterval(t *testing.T) {
|
|||
assert.Contains(t, err.Error(), "purge interval must be zero or positive")
|
||||
}
|
||||
|
||||
func TestStore_NewConfigured_Bad_EmptyDatabasePath(t *testing.T) {
|
||||
_, err := NewConfigured(StoreConfig{})
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "database path is empty")
|
||||
}
|
||||
|
||||
func TestStore_Config_Good(t *testing.T) {
|
||||
storeInstance, err := NewConfigured(StoreConfig{
|
||||
DatabasePath: ":memory:",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue