Some checks failed
CI / build-and-test (push) Failing after -31m12s
All internal entity lookups now use bigserial primary keys (int64) while GUIDs are retained for external/public identification. Updated store functions (TouchProject, UpdateThoughtMetadata, AddThoughtAttachment) to query by id instead of guid, added GetThoughtByID, changed semanticSearch and all tool helpers to use *int64 project IDs, and updated retry/backfill workers to use int64 thought IDs throughout.
70 lines
1.9 KiB
Go
70 lines
1.9 KiB
Go
package tools
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"git.warky.dev/wdevs/amcs/internal/mcperrors"
|
|
)
|
|
|
|
func TestLearningsAddRequiresSummary(t *testing.T) {
|
|
tool := &LearningsTool{}
|
|
|
|
_, _, err := tool.Add(context.Background(), nil, AddLearningInput{})
|
|
if err == nil {
|
|
t.Fatal("Add() error = nil, want error")
|
|
}
|
|
|
|
_, data := requireRPCError(t, err)
|
|
if data.Field != "summary" {
|
|
t.Fatalf("Add() error field = %q, want %q", data.Field, "summary")
|
|
}
|
|
}
|
|
|
|
func TestLearningsMethodsRequireConfiguredStore(t *testing.T) {
|
|
tool := &LearningsTool{}
|
|
|
|
t.Run("add", func(t *testing.T) {
|
|
_, _, err := tool.Add(context.Background(), nil, AddLearningInput{Summary: "Keep this"})
|
|
if err == nil {
|
|
t.Fatal("Add() error = nil, want error")
|
|
}
|
|
_, data := requireRPCError(t, err)
|
|
if data.Type != mcperrors.TypeInvalidInput {
|
|
t.Fatalf("Add() data.type = %q, want %q", data.Type, mcperrors.TypeInvalidInput)
|
|
}
|
|
})
|
|
|
|
t.Run("get", func(t *testing.T) {
|
|
_, _, err := tool.Get(context.Background(), nil, GetLearningInput{ID: 0})
|
|
if err == nil {
|
|
t.Fatal("Get() error = nil, want error")
|
|
}
|
|
_, data := requireRPCError(t, err)
|
|
if data.Type != mcperrors.TypeInvalidInput {
|
|
t.Fatalf("Get() data.type = %q, want %q", data.Type, mcperrors.TypeInvalidInput)
|
|
}
|
|
})
|
|
|
|
t.Run("list", func(t *testing.T) {
|
|
_, _, err := tool.List(context.Background(), nil, ListLearningsInput{})
|
|
if err == nil {
|
|
t.Fatal("List() error = nil, want error")
|
|
}
|
|
_, data := requireRPCError(t, err)
|
|
if data.Type != mcperrors.TypeInvalidInput {
|
|
t.Fatalf("List() data.type = %q, want %q", data.Type, mcperrors.TypeInvalidInput)
|
|
}
|
|
})
|
|
}
|
|
|
|
func TestNormalizeStringSliceTrimsDedupesAndDropsEmpties(t *testing.T) {
|
|
got := normalizeStringSlice([]string{" alpha ", "beta", "", "beta", "alpha"})
|
|
if len(got) != 2 {
|
|
t.Fatalf("normalizeStringSlice() len = %d, want 2", len(got))
|
|
}
|
|
if got[0] != "alpha" || got[1] != "beta" {
|
|
t.Fatalf("normalizeStringSlice() = %#v, want [alpha beta]", got)
|
|
}
|
|
}
|