feat(tools): implement CRUD operations for thoughts and projects
* Add tools for creating, retrieving, updating, and deleting thoughts. * Implement project management tools for creating and listing projects. * Introduce linking functionality between thoughts. * Add search and recall capabilities for thoughts based on semantic queries. * Implement statistics and summarization tools for thought analysis. * Create database migrations for thoughts, projects, and links. * Add helper functions for UUID parsing and project resolution.
This commit is contained in:
71
internal/config/loader_test.go
Normal file
71
internal/config/loader_test.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestResolvePathPrecedence(t *testing.T) {
|
||||
t.Setenv("OB1_CONFIG", "/tmp/from-env.yaml")
|
||||
|
||||
if got := ResolvePath("/tmp/explicit.yaml"); got != "/tmp/explicit.yaml" {
|
||||
t.Fatalf("ResolvePath explicit = %q, want %q", got, "/tmp/explicit.yaml")
|
||||
}
|
||||
|
||||
if got := ResolvePath(""); got != "/tmp/from-env.yaml" {
|
||||
t.Fatalf("ResolvePath env = %q, want %q", got, "/tmp/from-env.yaml")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadAppliesEnvOverrides(t *testing.T) {
|
||||
configPath := filepath.Join(t.TempDir(), "test.yaml")
|
||||
if err := os.WriteFile(configPath, []byte(`
|
||||
server:
|
||||
port: 8080
|
||||
mcp:
|
||||
path: "/mcp"
|
||||
auth:
|
||||
keys:
|
||||
- id: "test"
|
||||
value: "secret"
|
||||
database:
|
||||
url: "postgres://from-file"
|
||||
ai:
|
||||
provider: "litellm"
|
||||
embeddings:
|
||||
dimensions: 1536
|
||||
litellm:
|
||||
base_url: "http://localhost:4000/v1"
|
||||
api_key: "file-key"
|
||||
search:
|
||||
default_limit: 10
|
||||
max_limit: 50
|
||||
logging:
|
||||
level: "info"
|
||||
`), 0o600); err != nil {
|
||||
t.Fatalf("write config: %v", err)
|
||||
}
|
||||
|
||||
t.Setenv("OB1_DATABASE_URL", "postgres://from-env")
|
||||
t.Setenv("OB1_LITELLM_API_KEY", "env-key")
|
||||
t.Setenv("OB1_SERVER_PORT", "9090")
|
||||
|
||||
cfg, loadedFrom, err := Load(configPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
|
||||
if loadedFrom != configPath {
|
||||
t.Fatalf("loadedFrom = %q, want %q", loadedFrom, configPath)
|
||||
}
|
||||
if cfg.Database.URL != "postgres://from-env" {
|
||||
t.Fatalf("database url = %q, want env override", cfg.Database.URL)
|
||||
}
|
||||
if cfg.AI.LiteLLM.APIKey != "env-key" {
|
||||
t.Fatalf("litellm api key = %q, want env override", cfg.AI.LiteLLM.APIKey)
|
||||
}
|
||||
if cfg.Server.Port != 9090 {
|
||||
t.Fatalf("server port = %d, want 9090", cfg.Server.Port)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user