Problem
The repo has no usable unit-test infrastructure for the db/ and table/ layers. Today go test ./table/... ./reconciler/... panics outright without a live MongoDB:
log.Panicf(...)
github.com/go-core-stack/core/reconciler.performMongoSetup()
reconciler/reconciler_test.go:76
FAIL github.com/go-core-stack/core/reconciler 30.011s
FAIL github.com/go-core-stack/core/table 30.012s
This reproduces on main, so it is not a regression — it is a standing gap. errors/errors_test.go is currently the only package with tests that run unconditionally.
Why it matters now
This surfaced while reviewing #121, which introduces a new errors.Unavailable class and a isTransientMongoError / interpretMongoError classification path. The entire value of that change is correct classification, and there is currently no established place to assert it.
Notably, several of the affected functions are pure and need no MongoDB at all:
isTransientMongoError(err error) bool
interpretMongoError(err error) error
errors.IsUnavailable / errors.GetErrCode
- the
GetErrCode(err) != Unknown branch in CachedTable.DBFind
They can be driven entirely with fabricated errors. The blocker is not that these are untestable — it is that there is no pattern to follow and no way to run the surrounding package tests locally.
Proposal
- Make the
db/table/reconciler package tests skip cleanly (t.Skip) when no MongoDB is reachable, instead of log.Panicf. That alone makes go test ./... usable.
- Establish a pattern for MongoDB-backed tests — either a
testcontainers harness or a fake behind the existing collection interface.
- Add table-free unit tests for the pure error-classification helpers.
Item 1 is the cheap unblock and can land independently.
Notes
Deliberately scoped out of #121 — standing up test infra inside a behavior fix would bury the fix. Filing separately so #121 can land on its own merits.
Problem
The repo has no usable unit-test infrastructure for the
db/andtable/layers. Todaygo test ./table/... ./reconciler/...panics outright without a live MongoDB:This reproduces on
main, so it is not a regression — it is a standing gap.errors/errors_test.gois currently the only package with tests that run unconditionally.Why it matters now
This surfaced while reviewing #121, which introduces a new
errors.Unavailableclass and aisTransientMongoError/interpretMongoErrorclassification path. The entire value of that change is correct classification, and there is currently no established place to assert it.Notably, several of the affected functions are pure and need no MongoDB at all:
isTransientMongoError(err error) boolinterpretMongoError(err error) errorerrors.IsUnavailable/errors.GetErrCodeGetErrCode(err) != Unknownbranch inCachedTable.DBFindThey can be driven entirely with fabricated errors. The blocker is not that these are untestable — it is that there is no pattern to follow and no way to run the surrounding package tests locally.
Proposal
db/table/reconcilerpackage tests skip cleanly (t.Skip) when no MongoDB is reachable, instead oflog.Panicf. That alone makesgo test ./...usable.testcontainersharness or a fake behind the existing collection interface.Item 1 is the cheap unblock and can land independently.
Notes
Deliberately scoped out of #121 — standing up test infra inside a behavior fix would bury the fix. Filing separately so #121 can land on its own merits.