Skip to content

Commit 69f8729

Browse files
committed
enable tenv rule
1 parent 9264811 commit 69f8729

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ linters:
1919
- revive
2020
- staticcheck
2121
- stylecheck
22+
- tenv
2223
- typecheck
2324
- unconvert
2425
- unused

modules/base/tool_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package base
66
import (
77
"crypto/sha1"
88
"fmt"
9-
"os"
109
"testing"
1110
"time"
1211

@@ -172,9 +171,9 @@ func TestInt64sToStrings(t *testing.T) {
172171
// TODO: Test EntryIcon
173172

174173
func TestSetupGiteaRoot(t *testing.T) {
175-
_ = os.Setenv("GITEA_ROOT", "test")
174+
t.Setenv("GITEA_ROOT", "test")
176175
assert.Equal(t, "test", SetupGiteaRoot())
177-
_ = os.Setenv("GITEA_ROOT", "")
176+
t.Setenv("GITEA_ROOT", "")
178177
assert.NotEqual(t, "test", SetupGiteaRoot())
179178
}
180179

modules/user/user_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package user
55

66
import (
7-
"os"
87
"os/exec"
98
"runtime"
109
"strings"
@@ -36,7 +35,7 @@ func TestCurrentUsername(t *testing.T) {
3635
if user != whoami {
3736
t.Errorf("expected %s as user, got: %s", whoami, user)
3837
}
39-
os.Setenv("USER", "spoofed")
38+
t.Setenv("USER", "spoofed")
4039
user = CurrentUsername()
4140
if user != whoami {
4241
t.Errorf("expected %s as user, got: %s", whoami, user)

tests/integration/git_helper_for_declarative_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ func withKeyFile(t *testing.T, keyname string, callback func(string)) {
4040
assert.NoError(t, err)
4141

4242
// Setup ssh wrapper
43-
os.Setenv("GIT_SSH", path.Join(tmpDir, "ssh"))
44-
os.Setenv("GIT_SSH_COMMAND",
43+
t.Setenv("GIT_SSH", path.Join(tmpDir, "ssh"))
44+
t.Setenv("GIT_SSH_COMMAND",
4545
"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i \""+keyFile+"\"")
46-
os.Setenv("GIT_SSH_VARIANT", "ssh")
46+
t.Setenv("GIT_SSH_VARIANT", "ssh")
4747

4848
callback(keyFile)
4949
}

tests/integration/gpg_git_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ func TestGPGGit(t *testing.T) {
2929
err := os.Chmod(tmpDir, 0o700)
3030
assert.NoError(t, err)
3131

32-
oldGNUPGHome := os.Getenv("GNUPGHOME")
33-
err = os.Setenv("GNUPGHOME", tmpDir)
34-
assert.NoError(t, err)
35-
defer os.Setenv("GNUPGHOME", oldGNUPGHome)
32+
t.Setenv("GNUPGHOME", tmpDir)
3633

3734
// Need to create a root key
3835
rootKeyPair, err := importTestingKey()

0 commit comments

Comments
 (0)