Debian Codegraph @

patch_go1.14.go

raw
1 // Licensed under the MIT license, see LICENSE file for details.
2
3 //go:build go1.14
4 // +build go1.14
5
6 package quicktest
7
8 import "testing"
9
10 // Patch sets a variable to a temporary value for the duration of the test.
11 //
12 // It sets the value pointed to by the given destination to the given value,
13 // which must be assignable to the element type of the destination.
14 //
15 // At the end of the test the destination is set back to its original value
16 // using t.Cleanup.
17 //
18 // The top level Patch function is only available on Go >= 1.14. Use (*C).Patch
19 // when on prior versions.
20 func Patch(t testing.TB, dest, value interface{}) {
21 New(t).Patch(dest, value)
22 }
23
24 // Setenv sets an environment variable to a temporary value for the duration of
25 // the test.
26 //
27 // At the end of the test the environment variable is returned to its original
28 // value using t.Cleanup.
29 //
30 // The top level Setenv function is only available on Go >= 1.14. Use
31 // (*C).Setenv when on prior versions.
32 func Setenv(t testing.TB, name, val string) {
33 New(t).Setenv(name, val)
34 }
35
36 // Unsetenv unsets an environment variable for the duration of a test.
37 //
38 // The top level Unsetenv function is only available on Go >= 1.14. Use
39 // (*C).Unsetenv when on prior versions.
40 func Unsetenv(t testing.TB, name string) {
41 New(t).Unsetenv(name)
42 }