gitgram/aitimemachine/beads/cmd/bd/sync_parent_flag_test.go
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
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>
2026-06-23 14:14:09 +03:00

77 lines
2.3 KiB
Go

package main
import (
"testing"
"github.com/spf13/cobra"
"github.com/steveyegge/beads/internal/tracker"
)
// TestParentFlagRegistered verifies --parent flag exists on all tracker sync commands.
func TestParentFlagRegistered(t *testing.T) {
// Not parallel: accesses shared cobra command tree.
trackers := []struct {
name string
syncCmd *cobra.Command
}{
{"ado", adoSyncCmd},
{"jira", jiraSyncCmd},
{"linear", linearSyncCmd},
{"github", githubSyncCmd},
{"gitlab", gitlabSyncCmd},
}
for _, tc := range trackers {
t.Run(tc.name, func(t *testing.T) {
flag := tc.syncCmd.Flags().Lookup("parent")
if flag == nil {
t.Fatalf("%s sync command missing --parent flag", tc.name)
}
if flag.DefValue != "" {
t.Errorf("%s --parent default = %q, want empty", tc.name, flag.DefValue)
}
})
}
}
// TestParentFlagNotOnNotion verifies Notion sync doesn't have --parent
// since Notion doesn't have a parent-child hierarchy in the same way.
func TestParentFlagNotOnNotion(t *testing.T) {
// Not parallel: accesses shared cobra command tree.
flag := notionSyncCmd.Flags().Lookup("parent")
// Notion init has a --parent flag (for page parent), but sync should not
// accidentally inherit it. The sync command's --parent would be for tree-scoped push.
// For now, we don't add it to Notion since Notion doesn't support parent-child deps.
if flag != nil {
t.Log("Notion sync has --parent flag (may be intentional for future use)")
}
}
// TestIssuesAndParentAreMutuallyExclusive verifies that specifying both --issues
// and --parent on the same sync command returns an error.
//
// The two flags cannot be combined: --issues targets specific bead IDs while
// --parent scopes by subtree. Silently ANDing them would produce confusing
// results where only issues that appear in both sets are synced.
func TestIssuesAndParentAreMutuallyExclusive(t *testing.T) {
t.Parallel()
cmd := &cobra.Command{Use: "test"}
registerSelectiveSyncFlags(cmd)
if err := cmd.Flags().Set("issues", "bd-123"); err != nil {
t.Fatalf("setting --issues: %v", err)
}
if err := cmd.Flags().Set("parent", "bd-456"); err != nil {
t.Fatalf("setting --parent: %v", err)
}
var opts tracker.SyncOptions
err := applySelectiveSyncFlags(cmd, &opts, true /* push */)
if err == nil {
t.Fatal("expected error when both --issues and --parent are set, got nil")
}
}