agent-substrate / agent-substrate/substrate

Centralize the hand-rolled ateapipb.ControlClient test fake

Abierto
#1,044 4 comentarios 2 reacciones 0 asignados Ver en GitHub
area/tests kind/cleanup
Lenguaje dominante
Go
Estrellas
1.8k
Forks
316
Merge medio
2 d 43 min
PR fusionados (30 d)
287

Descripción

### PROBLEM
Five test files hand-roll a fake `ateapipb.ControlClient`, across four packages. #907 adds a sixth,
which is what surfaced this. That PR should land as it stands; consolidating these is follow-up
cleanup, not a prerequisite for it.
Surveyed at [`3f132c6d`](https://github.com/agent-substrate/substrate/commit/3f132c6d25fc50bb3bbd188ef46fa506cb684167) (`main`, 2026-08-17). Links are permalinks pinned to that commit so the line numbers can't drift; the type names are the durable anchor.

| type | package | location | RPCs stubbed |
|---|---|---|---|
| `mockControlClient` | `controllers` | [`actortemplate_controller_test.go:97`](https://github.com/agent-substrate/substrate/blob/3f132c6d25fc50bb3bbd188ef46fa506cb684167/cmd/atecontroller/internal/controllers/actortemplate_controller_test.go#L97) | `CreateAtespace`, `CreateActor` |
| `healthControlClient` | `router` | [`health_test.go:41`](https://github.com/agent-substrate/substrate/blob/3f132c6d25fc50bb3bbd188ef46fa506cb684167/cmd/atenet/internal/router/health_test.go#L41) | `ListActors` |
| `mockClient` | `ingress` | [`ingress_test.go:39`](https://github.com/agent-substrate/substrate/blob/3f132c6d25fc50bb3bbd188ef46fa506cb684167/cmd/atenet/internal/router/ingress/ingress_test.go#L39) | `ResumeActor` |
| `resumerMockClient` | `ingress` | [`resumer_test.go:32`](https://github.com/agent-substrate/substrate/blob/3f132c6d25fc50bb3bbd188ef46fa506cb684167/cmd/atenet/internal/router/ingress/resumer_test.go#L32) | `ResumeActor` |
| `egressMockClient` | `egress` | [`egress_test.go:197`](https://github.com/agent-substrate/substrate/blob/3f132c6d25fc50bb3bbd188ef46fa506cb684167/cmd/atenet/internal/router/egress/egress_test.go#L197) | `GetActor` |

The sixth, not yet merged: `fakeControlClient` in `internal/benchmarking/boomer/glutton/fixture_test.go`, package `glutton`, stubbing `CreateAtespace`, `CreateActor`, `ResumeActor`, `SuspendActor`, `DeleteActor`.

The two `ingress` ones live in the same package: the same one-RPC `ResumeActor` fake under two names. Their struct definitions are identical; only the method bodies differ, and `resumerMockClient` nil-guards `resumeFn` where `mockClient` calls it unconditionally.

All six are unexported and live in `_test.go` files, so none is importable. All six use the same idiom: embed `ateapipb.ControlClient` as an anonymous field and override the handful of RPCs the test needs, so calls to any RPC no fake overrides compile and nil-panic at call time.

The union across all six is seven RPCs: `CreateAtespace`, `CreateActor`, `ResumeActor`, `SuspendActor`, `DeleteActor`, `GetActor`, `ListActors`. `ControlClient` declares 28, so one embedding fake needs pluggable func fields for just those seven and inherits the rest.

### PROPOSAL

An exported fake in a non-`_test.go` file under repo-root `internal/`, following the precedent
already set by [`internal/volume/mock.go:52`](https://github.com/agent-substrate/substrate/blob/3f132c6d25fc50bb3bbd188ef46fa506cb684167/internal/volume/mock.go#L52) (`MockVolumePlugin`, with `NewMockVolumePlugin()` at
[`:55`](https://github.com/agent-substrate/substrate/blob/3f132c6d25fc50bb3bbd188ef46fa506cb684167/internal/volume/mock.go#L55)), which `cmd/ateapi/internal/controlapi/functional_test.go` and `controlapi/volumes_test.go` already call cross-package.

Placement has to be repo-root `internal/`: `cmd//internal/...` is importable only from under
that `cmd/`, and `pkg/proto/ateapipb` is generated. `pkg/` would work mechanically but makes a
test fake part of the public API surface. Put it in a dedicated package rather than an existing production one, so only tests link it and it never reaches a shipped binary.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.