mirror of
https://github.com/compose-spec/compose-go.git
synced 2026-11-24 20:00:00 +00:00
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>
99 lines
3 KiB
99 lines
3 KiB