test: use t.TempDir to create temporary test directory (#6164)

This commit is contained in:
Eng Zer Jun 2023-06-17 21:21:01 +08:00 committed by GitHub
parent 06cd843918
commit b868350fc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 77 deletions

View file

@ -4,7 +4,6 @@ import (
"context"
"errors"
"net"
"os"
"path"
"testing"
@ -72,11 +71,7 @@ func (m testServiceClient) Query(ctx context.Context, in *pb.DnsPacket, opts ...
}
func TestProxyUnix(t *testing.T) {
tdir, err := os.MkdirTemp("", "tmp*")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tdir)
tdir := t.TempDir()
fd := path.Join(tdir, "test.grpc")
listener, err := net.Listen("unix", fd)