Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
165 lines
3.9 KiB
Go
165 lines
3.9 KiB
Go
//go:build cgo
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
const testUserAlice = "alice"
|
|
|
|
func TestCommentsSuite(t *testing.T) {
|
|
t.Parallel()
|
|
tmpDir := t.TempDir()
|
|
testDB := filepath.Join(tmpDir, ".beads", "beads.db")
|
|
s := newTestStore(t, testDB)
|
|
ctx := context.Background()
|
|
|
|
t.Run("CommentsCommand", func(t *testing.T) {
|
|
// Create test issue
|
|
issue := &types.Issue{
|
|
Title: "Test Issue",
|
|
Description: "Test description",
|
|
Priority: 1,
|
|
IssueType: types.TypeBug,
|
|
Status: types.StatusOpen,
|
|
}
|
|
|
|
if err := s.CreateIssue(ctx, issue, "test-user"); err != nil {
|
|
t.Fatalf("Failed to create issue: %v", err)
|
|
}
|
|
|
|
t.Run("add comment", func(t *testing.T) {
|
|
comment, err := s.AddIssueComment(ctx, issue.ID, testUserAlice, "This is a test comment")
|
|
if err != nil {
|
|
t.Fatalf("Failed to add comment: %v", err)
|
|
}
|
|
|
|
if comment.IssueID != issue.ID {
|
|
t.Errorf("Expected issue ID %s, got %s", issue.ID, comment.IssueID)
|
|
}
|
|
if comment.Author != testUserAlice {
|
|
t.Errorf("Expected author alice, got %s", comment.Author)
|
|
}
|
|
if comment.Text != "This is a test comment" {
|
|
t.Errorf("Expected text 'This is a test comment', got %s", comment.Text)
|
|
}
|
|
})
|
|
|
|
t.Run("list comments", func(t *testing.T) {
|
|
comments, err := s.GetIssueComments(ctx, issue.ID)
|
|
if err != nil {
|
|
t.Fatalf("Failed to get comments: %v", err)
|
|
}
|
|
|
|
if len(comments) != 1 {
|
|
t.Errorf("Expected 1 comment, got %d", len(comments))
|
|
}
|
|
|
|
if comments[0].Text != "This is a test comment" {
|
|
t.Errorf("Expected comment text, got %s", comments[0].Text)
|
|
}
|
|
})
|
|
|
|
t.Run("multiple comments", func(t *testing.T) {
|
|
_, err := s.AddIssueComment(ctx, issue.ID, "bob", "Second comment")
|
|
if err != nil {
|
|
t.Fatalf("Failed to add second comment: %v", err)
|
|
}
|
|
|
|
comments, err := s.GetIssueComments(ctx, issue.ID)
|
|
if err != nil {
|
|
t.Fatalf("Failed to get comments: %v", err)
|
|
}
|
|
|
|
if len(comments) != 2 {
|
|
t.Errorf("Expected 2 comments, got %d", len(comments))
|
|
}
|
|
})
|
|
|
|
t.Run("comments on non-existent issue", func(t *testing.T) {
|
|
comments, err := s.GetIssueComments(ctx, "bd-nonexistent")
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error: %v", err)
|
|
}
|
|
|
|
if len(comments) != 0 {
|
|
t.Errorf("Expected 0 comments for non-existent issue, got %d", len(comments))
|
|
}
|
|
})
|
|
})
|
|
|
|
t.Run("AddComment", func(t *testing.T) {
|
|
issue := &types.Issue{
|
|
Title: "Test Issue for Comment",
|
|
Description: "Test description",
|
|
Priority: 1,
|
|
IssueType: types.TypeBug,
|
|
Status: types.StatusOpen,
|
|
}
|
|
|
|
if err := s.CreateIssue(ctx, issue, "test-user"); err != nil {
|
|
t.Fatalf("Failed to create issue: %v", err)
|
|
}
|
|
|
|
t.Run("comment added via storage API works", func(t *testing.T) {
|
|
comment, err := s.AddIssueComment(ctx, issue.ID, testUserAlice, "Test comment")
|
|
if err != nil {
|
|
t.Fatalf("Failed to add comment: %v", err)
|
|
}
|
|
|
|
if comment.Text != "Test comment" {
|
|
t.Errorf("Expected 'Test comment', got %s", comment.Text)
|
|
}
|
|
|
|
comments, err := s.GetIssueComments(ctx, issue.ID)
|
|
if err != nil {
|
|
t.Fatalf("Failed to get comments: %v", err)
|
|
}
|
|
|
|
if len(comments) != 1 {
|
|
t.Fatalf("Expected 1 comment, got %d", len(comments))
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
func TestIsUnknownOperationError(t *testing.T) {
|
|
t.Parallel()
|
|
tests := []struct {
|
|
name string
|
|
err error
|
|
expected bool
|
|
}{
|
|
{
|
|
name: "nil error",
|
|
err: nil,
|
|
expected: false,
|
|
},
|
|
{
|
|
name: "unknown operation error",
|
|
err: fmt.Errorf("unknown operation: test"),
|
|
expected: true,
|
|
},
|
|
{
|
|
name: "other error",
|
|
err: fmt.Errorf("some other error"),
|
|
expected: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
result := isUnknownOperationError(tt.err)
|
|
if result != tt.expected {
|
|
t.Errorf("Expected %v, got %v for error: %v", tt.expected, result, tt.err)
|
|
}
|
|
})
|
|
}
|
|
}
|