You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Eng Zer Jun 8b0aaa5f86
test: use `T.TempDir` to create temporary test directory (#21043)
A testing cleanup. 

This pull request replaces `os.MkdirTemp` with `t.TempDir`. We can use the `T.TempDir` function from the `testing` package to create temporary directory. The directory created by `T.TempDir` is automatically removed when the test and all its subtests complete. 

This saves us at least 2 lines (error check, and cleanup) on every instance, or in some cases adds cleanup that we forgot.

Reference: https://pkg.go.dev/testing#T.TempDir

```go
func TestFoo(t *testing.T) {
	// before
	tmpDir, err := os.MkdirTemp("", "")
	require.NoError(t, err)
	defer os.RemoveAll(tmpDir)

	// now
	tmpDir := t.TempDir()
}
```

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2 years ago
..
buffer.go migrations: add test for importing pull requests in gitea uploader (#18752) 2 years ago
buffer_test.go migrations: add test for importing pull requests in gitea uploader (#18752) 2 years ago
colors.go format with gofumpt (#18184) 2 years ago
colors_router.go Refactor Router Logger (#17308) 2 years ago
conn.go migrations: add test for importing pull requests in gitea uploader (#18752) 2 years ago
conn_test.go format with gofumpt (#18184) 2 years ago
console.go migrations: add test for importing pull requests in gitea uploader (#18752) 2 years ago
console_other.go Only set CanColorStdout / CanColorStderr to true if the stdout/stderr is a terminal (#19581) 2 years ago
console_test.go Fixed assert statements. (#16089) 3 years ago
console_windows.go Fix windows build error (#14263) 4 years ago
errors.go Better logging (#6038) (#6095) 5 years ago
event.go Empty log queue on flush and close (#19994) 2 years ago
file.go Go 1.19 format (#20758) 2 years ago
file_test.go test: use `T.TempDir` to create temporary test directory (#21043) 2 years ago
flags.go Log: Ensure FLAGS=none is -1 (#9287) 5 years ago
groutinelabel.go Add auto logging of goroutine pid label (#19212) 2 years ago
groutinelabel_test.go Add auto logging of goroutine pid label (#19212) 2 years ago
level.go Add an abstract json layout to make it's easier to change json library (#16528) 3 years ago
level_test.go Add an abstract json layout to make it's easier to change json library (#16528) 3 years ago
log.go Refactor Router Logger (#17308) 2 years ago
log_test.go format with gofumpt (#18184) 2 years ago
logger.go format with gofumpt (#18184) 2 years ago
multichannel.go Disable doctor logging on panic (#20847) 2 years ago
provider.go migrations: add test for importing pull requests in gitea uploader (#18752) 2 years ago
smtp.go Go 1.19 format (#20758) 2 years ago
smtp_test.go Fixed assert statements. (#16089) 3 years ago
stack.go format with gofumpt (#18184) 2 years ago
writer.go format with gofumpt (#18184) 2 years ago
writer_test.go Fixed assert statements. (#16089) 3 years ago