Merge pull request 'Add tenv linter and fix current issues' (#4556) from thefox/add-tenv-linter into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4556 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
aaf90f6506
5 changed files with 8 additions and 11 deletions
|
@ -19,6 +19,7 @@ linters:
|
||||||
- revive
|
- revive
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- stylecheck
|
- stylecheck
|
||||||
|
- tenv
|
||||||
- typecheck
|
- typecheck
|
||||||
- unconvert
|
- unconvert
|
||||||
- unused
|
- unused
|
||||||
|
|
|
@ -6,7 +6,6 @@ package base
|
||||||
import (
|
import (
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -168,9 +167,9 @@ func TestInt64sToStrings(t *testing.T) {
|
||||||
// TODO: Test EntryIcon
|
// TODO: Test EntryIcon
|
||||||
|
|
||||||
func TestSetupGiteaRoot(t *testing.T) {
|
func TestSetupGiteaRoot(t *testing.T) {
|
||||||
_ = os.Setenv("GITEA_ROOT", "test")
|
t.Setenv("GITEA_ROOT", "test")
|
||||||
assert.Equal(t, "test", SetupGiteaRoot())
|
assert.Equal(t, "test", SetupGiteaRoot())
|
||||||
_ = os.Setenv("GITEA_ROOT", "")
|
t.Setenv("GITEA_ROOT", "")
|
||||||
assert.NotEqual(t, "test", SetupGiteaRoot())
|
assert.NotEqual(t, "test", SetupGiteaRoot())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -36,7 +35,7 @@ func TestCurrentUsername(t *testing.T) {
|
||||||
if user != whoami {
|
if user != whoami {
|
||||||
t.Errorf("expected %s as user, got: %s", whoami, user)
|
t.Errorf("expected %s as user, got: %s", whoami, user)
|
||||||
}
|
}
|
||||||
os.Setenv("USER", "spoofed")
|
t.Setenv("USER", "spoofed")
|
||||||
user = CurrentUsername()
|
user = CurrentUsername()
|
||||||
if user != whoami {
|
if user != whoami {
|
||||||
t.Errorf("expected %s as user, got: %s", whoami, user)
|
t.Errorf("expected %s as user, got: %s", whoami, user)
|
||||||
|
|
|
@ -40,10 +40,10 @@ func withKeyFile(t *testing.T, keyname string, callback func(string)) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// Setup ssh wrapper
|
// Setup ssh wrapper
|
||||||
os.Setenv("GIT_SSH", path.Join(tmpDir, "ssh"))
|
t.Setenv("GIT_SSH", path.Join(tmpDir, "ssh"))
|
||||||
os.Setenv("GIT_SSH_COMMAND",
|
t.Setenv("GIT_SSH_COMMAND",
|
||||||
"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i \""+keyFile+"\"")
|
"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i \""+keyFile+"\"")
|
||||||
os.Setenv("GIT_SSH_VARIANT", "ssh")
|
t.Setenv("GIT_SSH_VARIANT", "ssh")
|
||||||
|
|
||||||
callback(keyFile)
|
callback(keyFile)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,8 @@ func TestGPGGit(t *testing.T) {
|
||||||
err := os.Chmod(tmpDir, 0o700)
|
err := os.Chmod(tmpDir, 0o700)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
oldGNUPGHome := os.Getenv("GNUPGHOME")
|
t.Setenv("GNUPGHOME", tmpDir)
|
||||||
err = os.Setenv("GNUPGHOME", tmpDir)
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
defer os.Setenv("GNUPGHOME", oldGNUPGHome)
|
|
||||||
|
|
||||||
// Need to create a root key
|
// Need to create a root key
|
||||||
rootKeyPair, err := importTestingKey()
|
rootKeyPair, err := importTestingKey()
|
||||||
|
|
Loading…
Add table
Reference in a new issue