Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace tenv linter with usetesting #6776

Merged
merged 3 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ linters:
- perfsprint
- revive
- staticcheck
- tenv
- testifylint
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting

issues:
# Maximum issues count per one linter.
Expand Down
26 changes: 2 additions & 24 deletions detectors/gcp/cloud-function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package gcp
import (
"context"
"errors"
"os"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -57,20 +56,8 @@ type want struct {
}

func TestCloudFunctionDetect(t *testing.T) {
oldValue, ok := os.LookupEnv(gcpFunctionNameKey)
if !ok {
err := os.Setenv(gcpFunctionNameKey, functionName)
if err != nil {
t.Error("unable to set environment variable ", err)
}
}
defer func() {
if !ok {
_ = os.Unsetenv(gcpFunctionNameKey)
} else {
_ = os.Setenv(gcpFunctionNameKey, oldValue)
}
}()
t.Setenv(gcpFunctionNameKey, functionName)

tests := []struct {
name string
cr *CloudRun
Expand Down Expand Up @@ -143,15 +130,6 @@ func TestCloudFunctionDetect(t *testing.T) {
}

func TestNotOnCloudFunction(t *testing.T) {
oldValue, ok := os.LookupEnv(gcpFunctionNameKey)
if ok {
_ = os.Unsetenv(gcpFunctionNameKey)
}
defer func() {
if ok {
_ = os.Setenv(gcpFunctionNameKey, oldValue)
}
}()
detector := NewCloudFunction()
res, err := detector.Detect(context.Background())
if err != nil {
Expand Down
Loading