compose-go/loader/tests/develop_test.go
Nicolas De Loof f81659dea5 lint: enable forbidigo to require t.Context() in tests
Tests that build their own context.Background() or context.TODO() are not
bound to the lifecycle of the test: the context is never cancelled when the
test ends. testing.T.Context() (Go 1.24) is cancelled right before the
Cleanup functions run, which is what a test wants.

Enable forbidigo as docker/compose does (type-aware, tests only, so the
production code and cmd/ are unaffected) and migrate the 168 existing
usages in tests to t.Context() (b.Context() in benchmarks). The loadYAML
test helpers now take the context from their caller instead of creating
one, and the graph tests no longer wrap a context they cancel in Cleanup
since t.Context() already gives that.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2026-10-22 17:10:59 +02:00

99 lines
3 KiB