bench-forgejo/services
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>
2022-09-04 16:14:53 +01:00
..
agit Add more linters to improve code readability (#19989) 2022-06-20 12:02:49 +02:00
asymkey Refactor AssertExistsAndLoadBean to use generics (#20797) 2022-08-16 10:22:25 +08:00
attachment Refactor AssertExistsAndLoadBean to use generics (#20797) 2022-08-16 10:22:25 +08:00
auth Share HTML template renderers and create a watcher framework (#20218) 2022-08-28 10:43:25 +01:00
automerge Add more linters to improve code readability (#19989) 2022-06-20 12:02:49 +02:00
comments Move issues related files into models/issues (#19931) 2022-06-13 17:37:59 +08:00
context Move almost all functions' parameter db.Engine to context.Context (#19748) 2022-05-20 22:08:52 +08:00
cron Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
externalaccount Refactor auth package (#17962) 2022-01-02 21:12:35 +08:00
forms refactor webhook *NewPost (#20729) 2022-08-11 17:48:23 +02:00
gitdiff Refactor AssertExistsAndLoadBean to use generics (#20797) 2022-08-16 10:22:25 +08:00
issue Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
lfs Move some code into models/git (#19879) 2022-06-12 23:51:54 +08:00
mailer Share HTML template renderers and create a watcher framework (#20218) 2022-08-28 10:43:25 +01:00
migrations Add more checks in migration code (#21011) 2022-09-04 13:47:56 +03:00
mirror Add new API endpoints for push mirrors management (#19841) 2022-07-30 18:45:59 +02:00
org Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
packages Replace ServeStream with ServeContent (#20903) 2022-08-25 12:05:21 -04:00
pull Prevent 500 is head repo does not have PullRequest unit in IsUserAllowedToUpdate (#20839) 2022-08-18 13:31:15 +03:00
release Add more checks in migration code (#21011) 2022-09-04 13:47:56 +03:00
repository fix hard-coded timeout and error panic in API archive download endpoint (#20925) 2022-08-29 11:45:20 +02:00
task Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
user Refactor AssertExistsAndLoadBean to use generics (#20797) 2022-08-16 10:22:25 +08:00
webhook Update a few go dependencies (#21022) 2022-09-01 23:13:17 +02:00
wiki test: use T.TempDir to create temporary test directory (#21043) 2022-09-04 16:14:53 +01:00