Skip to content

Commit 4cff690

Browse files
committed
add test case
1 parent 34ac2e7 commit 4cff690

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

test/testdata/tenv_test.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,34 @@ var (
1313
func setup() {
1414
os.Setenv("a", "b") // OK
1515
err := os.Setenv("a", "b") // OK
16-
if err != nil {
16+
_ = err
17+
if err := os.Setenv("a", "b"); err != nil { // OK
1718
_ = err
1819
}
1920
}
2021

2122
func TestF(t *testing.T) {
22-
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF"
23+
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF"
24+
err := os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF"
25+
_ = err
2326
if err := os.Setenv("a", "b"); err != nil { // ERROR "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF"
2427
_ = err
2528
}
2629
}
2730

2831
func BenchmarkF(b *testing.B) {
29-
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF"
32+
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF"
33+
err := os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF"
34+
_ = err
3035
if err := os.Setenv("a", "b"); err != nil { // ERROR "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF"
3136
_ = err
3237
}
3338
}
3439

3540
func testTB(tb testing.TB) {
36-
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB"
41+
os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB"
42+
err := os.Setenv("a", "b") // ERROR "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB"
43+
_ = err
3744
if err := os.Setenv("a", "b"); err != nil { // ERROR "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB"
3845
_ = err
3946
}

0 commit comments

Comments
 (0)