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
..
install Improve install code to avoid low-level mistakes. (#17779) 3 years ago
paginator Use a struct as test options (#19393) 2 years ago
common.go Modify milestone search keywords to be case insensitive again (#20513) 2 years ago
consistency.go Move issues related files into models/issues (#19931) 2 years ago
context.go Fix various typos (#20338) 2 years ago
convert.go Refactor auth package (#17962) 3 years ago
engine.go Allow manager logging to set SQL (#20064) 2 years ago
engine_test.go test: use `T.TempDir` to create temporary test directory (#21043) 2 years ago
error.go Delete related PullAutoMerge and ReviewState on User/Repo Deletion (#19649) 2 years ago
index.go Add more linters to improve code readability (#19989) 2 years ago
iterate.go Add migrate repo archiver and packages storage support on command line (#20757) 2 years ago
list_options.go Add more linters to improve code readability (#19989) 2 years ago
log.go Allow manager logging to set SQL (#20064) 2 years ago
main_test.go Move tests as seperate sub packages to reduce duplicated file names (#19951) 2 years ago
name.go Move user related model into models/user (#17781) 3 years ago
search.go Move user related model into models/user (#17781) 3 years ago
sequence.go Move db related basic functions to models/db (#17075) 3 years ago
sql_postgres_with_schema.go Add more linters to improve code readability (#19989) 2 years ago