0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-25 23:24:51 +01:00
gitea/routers/web/repo
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
..
activity.go Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
attachment.go
blame.go
branch.go
cherry_pick.go
commit.go
compare.go Support Issue forms and PR forms (#20987) 2022-09-02 15:58:49 +08:00
download.go
editor.go Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
editor_test.go
find.go
http.go
http_test.go
issue.go Support Issue forms and PR forms (#20987) 2022-09-02 15:58:49 +08:00
issue_content_history.go
issue_dependency.go
issue_label.go
issue_label_test.go
issue_lock.go
issue_stopwatch.go
issue_test.go
issue_timetrack.go
issue_watch.go
lfs.go
main_test.go
middlewares.go
migrate.go
milestone.go
packages.go Show hint to link package to repo when viewing empty repo package list (#20504) 2022-07-27 19:58:21 +08:00
patch.go
projects.go
projects_test.go
pull.go Support Issue forms and PR forms (#20987) 2022-09-02 15:58:49 +08:00
pull_review.go
release.go Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
release_test.go Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
render.go
repo.go fix hard-coded timeout and error panic in API archive download endpoint (#20925) 2022-08-29 11:45:20 +02:00
search.go
setting.go Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
setting_protected_branch.go
settings_test.go test: use T.TempDir to create temporary test directory (#21043) 2022-09-04 16:14:53 +01:00
tag.go
topic.go
treelist.go
view.go Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
view_test.go
webhook.go Fill the specified ref in webhook test payload (#20961) 2022-09-04 12:18:07 +03:00
wiki.go Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
wiki_test.go