mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-13 03:42:35 -06:00
3368497a96
The `test.WithTempFS` helper is used _extensively_ throughout our tests. Since `t.TempDir()` became a thing (Go 1.16), it probably shouldn't be, as that function does all the same things but in a more idiomatic manner. Main issues with `test.WithTempFS`: - It doesn't take a `*testing.T`, making failures reported without correct/helpful location. - It creates a new scope for no particular reason, where it could just have returned the root directory instead. An additional scope == an additionl level of indentation. This change adds the new `test.TempDir` and `test.TempDirOf` functions, which tries to address these issues. There are way too many places where `test.WithTempFS` is used for me to fix in a single PR, so more will have to come later. Most of the changes here don't even use the new functions, but replace the use of `test.WithTempFS` with `t.TempDir()` directly, as no files were passed to the function there. Also: - Replace a number of `reflect.DeepEqual` calls with better alternatives (not using reflection) Recommended reviewing with whitespace diffs hidden! Signed-off-by: Anders Eknert <anders.eknert@apple.com>