Skip to content

Commit

Permalink
Replace tenv with usetesting (#6313)
Browse files Browse the repository at this point in the history
The `tenv` linter is deprecated in favor of `usetesting`.
  • Loading branch information
dmathieu authored Feb 13, 2025
1 parent 44ea53b commit f62232f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ linters:
- perfsprint
- revive
- staticcheck
- tenv
- testifylint
- typecheck
- unconvert
- unused
- unparam
- usestdlibvars
- usetesting

issues:
# Maximum issues count per one linter.
Expand Down
4 changes: 2 additions & 2 deletions sdk/resource/host_id_readfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func TestReadFileExistent(t *testing.T) {
fileContents := "foo"

f, err := os.CreateTemp("", "readfile_")
f, err := os.CreateTemp(t.TempDir(), "readfile_")
require.NoError(t, err)

defer os.Remove(f.Name())
Expand All @@ -31,7 +31,7 @@ func TestReadFileExistent(t *testing.T) {

func TestReadFileNonExistent(t *testing.T) {
// create unique filename
f, err := os.CreateTemp("", "readfile_")
f, err := os.CreateTemp(t.TempDir(), "readfile_")
require.NoError(t, err)

// make file non-existent
Expand Down
3 changes: 1 addition & 2 deletions sdk/trace/batch_span_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/binary"
"errors"
"fmt"
"os"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -267,7 +266,7 @@ func TestNewBatchSpanProcessorWithEnvOptions(t *testing.T) {
for _, option := range options {
t.Run(option.name, func(t *testing.T) {
for k, v := range option.envs {
require.NoError(t, os.Setenv(k, v))
t.Setenv(k, v)
}

te := testBatchExporter{}
Expand Down
3 changes: 1 addition & 2 deletions sdk/trace/span_limits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package trace

import (
"context"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -115,7 +114,7 @@ func TestSettingSpanLimits(t *testing.T) {
t.Cleanup(func() { require.NoError(t, es.Restore()) })
for k, v := range test.env {
es.Record(k)
require.NoError(t, os.Setenv(k, v))
t.Setenv(k, v)
}
}

Expand Down

0 comments on commit f62232f

Please sign in to comment.