mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
all: use tstest.Replace more
Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -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() {
|
||||
|
Reference in New Issue
Block a user