all: use tstest.Replace more

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2023-03-04 12:04:55 -08:00
committed by Maisem Ali
parent 57a44846ae
commit 1a30b2d73f
12 changed files with 35 additions and 58 deletions

View File

@@ -15,10 +15,11 @@ import (
// Replace replaces the value of target with val.
// The old value is restored when the test ends.
func Replace[T any](t *testing.T, target *T, val T) {
func Replace[T any](t testing.TB, target *T, val T) {
t.Helper()
if target == nil {
t.Fatalf("Replace: nil pointer")
panic("unreachable") // pacify staticcheck
}
old := *target
t.Cleanup(func() {