Approval is moving the note into raw/<wing>/ (the watcher ingests it there); a dedicated approve tool is tracked separately. Proposal reason is written Go-quoted so LLM text cannot start a frontmatter key; pinned by a mutation-checked test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
package api
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func writeParked(t *testing.T, brainDir, name, content string) {
|
|
t.Helper()
|
|
dir := filepath.Join(brainDir, "raw", "needs-review")
|
|
require.NoError(t, os.MkdirAll(dir, 0o755))
|
|
require.NoError(t, os.WriteFile(filepath.Join(dir, name), []byte(content), 0o644))
|
|
}
|
|
|
|
func TestListPending_ShowsParkedNotesWithTheirProposal(t *testing.T) {
|
|
dir := t.TempDir()
|
|
writeRaw(t, dir, "fresh.md", "---\ncreated_at: 2026-10-20T08:00:00Z\n---\nA note not yet processed.\n")
|
|
writeParked(t, dir, "unsure.md", "---\nproposed_wing: radar\nproposal_confidence: 0.55\nproposal_reason: \"below threshold\"\ncreated_at: 2026-10-19T08:00:00Z\n---\nBody of the unsure note.\n")
|
|
|
|
got, err := ListPending(dir)
|
|
require.NoError(t, err)
|
|
require.Len(t, got, 2)
|
|
|
|
assert.Equal(t, "unsure.md", got[0].Filename, "oldest first across both queues")
|
|
assert.Equal(t, "needs-review", got[0].Queue)
|
|
assert.Equal(t, "radar", got[0].ProposedWing)
|
|
assert.Equal(t, "below threshold", got[0].ProposalReason)
|
|
assert.InDelta(t, 0.55, got[0].ProposalConfidence, 1e-9)
|
|
assert.Contains(t, got[0].Excerpt, "Body of the unsure note")
|
|
assert.NotContains(t, got[0].Excerpt, "proposed_wing", "excerpt is body, not frontmatter")
|
|
|
|
assert.Equal(t, "fresh.md", got[1].Filename)
|
|
assert.Empty(t, got[1].Queue, "a top-level note has no queue label")
|
|
assert.Empty(t, got[1].ProposedWing)
|
|
}
|
|
|
|
func TestListPending_ParkedSymlinkIsNotListed(t *testing.T) {
|
|
dir := t.TempDir()
|
|
outside := filepath.Join(t.TempDir(), "secret.md")
|
|
require.NoError(t, os.WriteFile(outside, []byte("outside"), 0o644))
|
|
require.NoError(t, os.MkdirAll(filepath.Join(dir, "raw", "needs-review"), 0o755))
|
|
require.NoError(t, os.Symlink(outside, filepath.Join(dir, "raw", "needs-review", "link.md")))
|
|
|
|
got, err := ListPending(dir)
|
|
require.NoError(t, err)
|
|
assert.Empty(t, got, "same symlink rule as the top level (#153)")
|
|
}
|