As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Unverified Commit f7f60f1a authored by Ash McKenzie's avatar Ash McKenzie
Browse files

Prefer t.TempDir() over os.MkdirTemp()

parent 74bd7c60
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -84,7 +84,8 @@ func StartGitalyServer(t *testing.T, network string) (string, *TestGitalyServer)
switch network {
case "unix":
tempDir, _ := os.MkdirTemp("", "gitlab-shell-test-api")
tempDir := t.TempDir()
gitalySocketPath := path.Join(tempDir, "gitaly.sock")
t.Cleanup(func() { require.NoError(t, os.RemoveAll(tempDir)) })
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@ type TestRequestHandler struct {
func StartSocketHttpServer(t *testing.T, handlers []TestRequestHandler) string {
t.Helper()
tempDir, _ := os.MkdirTemp("", "gitlab-shell-test-api")
tempDir := t.TempDir()
t.Cleanup(func() { os.RemoveAll(tempDir) })
testSocket := path.Join(tempDir, "internal.sock")
Loading
Loading
Loading
Loading
@@ -262,12 +262,11 @@ func buildClient(t *testing.T, addr string, hostKey ed25519.PublicKey) *ssh.Clie
func configureSSHD(t *testing.T, apiServer string) (string, ed25519.PublicKey) {
t.Helper()
dir, err := os.MkdirTemp("", "gitlab-sshd-acceptance-test-")
require.NoError(t, err)
t.Cleanup(func() { os.RemoveAll(dir) })
tempDir := t.TempDir()
t.Cleanup(func() { os.RemoveAll(tempDir) })
configFile := filepath.Join(dir, "config.yml")
hostKeyFile := filepath.Join(dir, "hostkey")
configFile := filepath.Join(tempDir, "config.yml")
hostKeyFile := filepath.Join(tempDir, "hostkey")
pub, priv, err := ed25519.GenerateKey(nil)
require.NoError(t, err)
Loading
Loading
@@ -279,7 +278,7 @@ func configureSSHD(t *testing.T, apiServer string) (string, ed25519.PublicKey) {
hostKeyData := pem.EncodeToMemory(block)
require.NoError(t, os.WriteFile(hostKeyFile, hostKeyData, 0400))
return dir, pub
return tempDir, pub
}
func startSSHD(t *testing.T, dir string) string {
Loading
Loading
Loading
Loading
@@ -61,12 +61,11 @@ func TestConfigureWithDebugLogLevel(t *testing.T) {
}
func TestConfigureWithPermissionError(t *testing.T) {
tmpPath, err := os.MkdirTemp(os.TempDir(), "logtest-")
require.NoError(t, err)
defer os.RemoveAll(tmpPath)
tempDir := t.TempDir()
defer os.RemoveAll(tempDir)
config := config.Config{
LogFile: tmpPath,
LogFile: tempDir,
LogFormat: "json",
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment