[#1459] .golanci.yml: Add tenv linter, fix issues
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m42s
DCO action / DCO (pull_request) Successful in 2m47s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m51s
Tests and linters / gopls check (pull_request) Successful in 3m39s
Vulncheck / Vulncheck (pull_request) Successful in 3m47s
Tests and linters / Lint (pull_request) Successful in 4m10s
Build / Build Components (pull_request) Successful in 4m24s
Tests and linters / Staticcheck (pull_request) Successful in 5m11s
Tests and linters / Tests (pull_request) Successful in 6m41s
Tests and linters / Tests with -race (pull_request) Successful in 7m6s
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m42s
DCO action / DCO (pull_request) Successful in 2m47s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m51s
Tests and linters / gopls check (pull_request) Successful in 3m39s
Vulncheck / Vulncheck (pull_request) Successful in 3m47s
Tests and linters / Lint (pull_request) Successful in 4m10s
Build / Build Components (pull_request) Successful in 4m24s
Tests and linters / Staticcheck (pull_request) Successful in 5m11s
Tests and linters / Tests (pull_request) Successful in 6m41s
Tests and linters / Tests with -race (pull_request) Successful in 7m6s
Refs #1309 Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
9cf5755aa0
commit
60427905df
3 changed files with 3 additions and 16 deletions
|
@ -88,5 +88,6 @@ linters:
|
||||||
- testifylint
|
- testifylint
|
||||||
- protogetter
|
- protogetter
|
||||||
- intrange
|
- intrange
|
||||||
|
- tenv
|
||||||
disable-all: true
|
disable-all: true
|
||||||
fast: false
|
fast: false
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package config_test
|
package config_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -38,8 +37,7 @@ func TestConfigEnv(t *testing.T) {
|
||||||
|
|
||||||
envName := strings.ToUpper(
|
envName := strings.ToUpper(
|
||||||
strings.Join([]string{config.EnvPrefix, section, name}, configViper.EnvSeparator))
|
strings.Join([]string{config.EnvPrefix, section, name}, configViper.EnvSeparator))
|
||||||
err := os.Setenv(envName, value)
|
t.Setenv(envName, value)
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
c := configtest.EmptyConfig()
|
c := configtest.EmptyConfig()
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func fromFile(path string) *config.Config {
|
func fromFile(path string) *config.Config {
|
||||||
os.Clearenv() // ENVs have priority over config files, so we do this in tests
|
|
||||||
|
|
||||||
return config.New(path, "", "")
|
return config.New(path, "", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,15 +38,6 @@ func ForEachFileType(pref string, f func(*config.Config)) {
|
||||||
|
|
||||||
// ForEnvFileType creates config from `<pref>.env` file.
|
// ForEnvFileType creates config from `<pref>.env` file.
|
||||||
func ForEnvFileType(t testing.TB, pref string, f func(*config.Config)) {
|
func ForEnvFileType(t testing.TB, pref string, f func(*config.Config)) {
|
||||||
envs := os.Environ()
|
|
||||||
t.Cleanup(func() {
|
|
||||||
os.Clearenv()
|
|
||||||
for _, env := range envs {
|
|
||||||
keyValue := strings.Split(env, "=")
|
|
||||||
os.Setenv(keyValue[0], keyValue[1])
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
f(fromEnvFile(t, pref+".env"))
|
f(fromEnvFile(t, pref+".env"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +62,6 @@ func loadEnv(t testing.TB, path string) {
|
||||||
|
|
||||||
v = strings.Trim(v, `"`)
|
v = strings.Trim(v, `"`)
|
||||||
|
|
||||||
err = os.Setenv(k, v)
|
t.Setenv(k, v)
|
||||||
require.NoError(t, err, "can't set environment variable")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue