fix: add missing LinkBranch stubs to test doubles

Fix go vet/test failures by adding LinkBranch methods to stubForge, prCapturingForge, testForge, and fakeForge. Update test data from 'sam/archie' to 'acme/widget' and state label defaults from 'archie:*' to 'agent:*'. Add Taskfile.yml for project build automation. Implement container self-network detection so spawned agents join the daemon's Docker network.
This commit is contained in:
sam committed 2026-07-24 13:32:50 +10:00
1 parent d80401d595
commit 6ebbd3b2cf
22 files changed
+273 -138

No files matched your search

+2 -2
View File
@@ -22,7 +22,7 @@ func TestBootTaskID(t *testing.T) {
t.Run("valid task.json — dedicated per-task mode", func(t *testing.T) {
dir := t.TempDir()
data, err := json.Marshal(container.TaskPayload{ID: 42, Owner: "sam", Repo: "archie"})
data, err := json.Marshal(container.TaskPayload{ID: 42, Owner: "acme", Repo: "widget"})
if err != nil {
t.Fatal(err)
}
@@ -48,7 +48,7 @@ func TestBootTaskID(t *testing.T) {
t.Run("zero ID falls back to shared pool mode", func(t *testing.T) {
dir := t.TempDir()
data, _ := json.Marshal(container.TaskPayload{Owner: "sam", Repo: "archie"})
data, _ := json.Marshal(container.TaskPayload{Owner: "acme", Repo: "widget"})
if err := os.WriteFile(filepath.Join(dir, "task.json"), data, 0o644); err != nil {
t.Fatal(err)
}
+9 -5
View File
@@ -93,6 +93,10 @@ func (f *prCapturingForge) VerifyPush(context.Context, string, string) error {
panic("unexpected call")
}
func (f *prCapturingForge) LinkBranch(context.Context, string, string, int, string) error {
panic("unexpected call")
}
// newLocalRemote mirrors worktree_test.go's helper: a bare repo with one
// commit on main, reachable via file://<host>/<owner>/<repo>.git.
func newLocalRemote(t *testing.T, owner, repo string) string {
@@ -140,12 +144,12 @@ func TestRunTaskExecutesBootstrapWorkflowEndToEnd(t *testing.T) {
t.Skip("git not installed")
}
ctx := context.Background()
host := newLocalRemote(t, "sam", "archie")
host := newLocalRemote(t, "acme", "widget")
// archied side: real Store, a capturing Forge, and the Manager that
// actually holds the (unused-for-file-remotes) push token.
st := store.OpenTest(t)
if _, err := st.EnqueueIssue(ctx, "sam", "archie", 1, "feat: bootstrap test", "", "bootstrap"); err != nil {
if _, err := st.EnqueueIssue(ctx, "acme", "widget", 1, "feat: bootstrap test", "", "bootstrap"); err != nil {
t.Fatalf("enqueue: %v", err)
}
task, err := st.ClaimNext(ctx)
@@ -164,7 +168,7 @@ func TestRunTaskExecutesBootstrapWorkflowEndToEnd(t *testing.T) {
// The daemon always prepares the worktree before container acquire —
// reproduce that here so the container's bind mount has real content.
hostDir, _, err := daemonTrees.Prepare(ctx, "sam", "archie", "main", 1, task.Title, "", "bootstrap")
hostDir, _, err := daemonTrees.Prepare(ctx, "acme", "widget", "main", 1, task.Title, "", "bootstrap")
if err != nil {
t.Fatalf("daemon-side prepare: %v", err)
}
@@ -195,7 +199,7 @@ func TestRunTaskExecutesBootstrapWorkflowEndToEnd(t *testing.T) {
req := taskrun.Request{
Task: task,
Repo: config.Repo{Owner: "sam", Name: "archie", Base: "main"},
Repo: config.Repo{Owner: "acme", Name: "widget", Base: "main"},
Cfg: config.Config{}.ForTask(),
}
@@ -216,7 +220,7 @@ func TestRunTaskExecutesBootstrapWorkflowEndToEnd(t *testing.T) {
// The authoritative state landed in archied's store via storerpc, not
// just in the in-memory tc.Task.
stored, err := st.TaskByIssue(ctx, "sam", "archie", 1)
stored, err := st.TaskByIssue(ctx, "acme", "widget", 1)
if err != nil || stored == nil {
t.Fatalf("TaskByIssue: (%+v, %v)", stored, err)
}
+6 -3
View File
@@ -53,6 +53,9 @@ func (stubForge) CreateIssue(context.Context, string, string, string, string, []
}
func (stubForge) React(context.Context, string, string, int, string) error { panic("unexpected call") }
func (stubForge) VerifyPush(context.Context, string, string) error { panic("unexpected call") }
func (stubForge) LinkBranch(context.Context, string, string, int, string) error {
panic("unexpected call")
}
func startEmbeddedNATS(t *testing.T) *server.Server {
t.Helper()
@@ -90,7 +93,7 @@ func TestRegisterTaskRPCServersReachableFromClient(t *testing.T) {
ctx := context.Background()
storeClient := &storerpc.Client{Conn: clientConn, Timeout: 2 * time.Second}
if _, err := st.EnqueueIssue(ctx, "sam", "archie", 1, "t", "b", ""); err != nil {
if _, err := st.EnqueueIssue(ctx, "acme", "widget", 1, "t", "b", ""); err != nil {
t.Fatalf("enqueue: %v", err)
}
task, err := st.ClaimNext(ctx)
@@ -102,12 +105,12 @@ func TestRegisterTaskRPCServersReachableFromClient(t *testing.T) {
}
forgeClient := &forgerpc.Client{Conn: clientConn, Timeout: 2 * time.Second}
if _, err := forgeClient.Comment(ctx, "sam", "archie", 1, "hi"); err != nil {
if _, err := forgeClient.Comment(ctx, "acme", "widget", 1, "hi"); err != nil {
t.Fatalf("forgerpc Comment unreachable: %v", err)
}
treesClient := &worktreerpc.Client{Conn: clientConn, Timeout: 2 * time.Second}
if _, _, err := treesClient.Prepare(ctx, "sam", "archie", "main", 1, "feat: x", "", ""); err == nil {
if _, _, err := treesClient.Prepare(ctx, "acme", "widget", "main", 1, "feat: x", "", ""); err == nil {
t.Fatal("expected Prepare to fail against a non-git remote, proving the RPC round-tripped")
} else if err.Error() == "" {
t.Fatal("expected a non-empty error from the worktreerpc round trip")