0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-23 19:24:38 +01:00
gitea/modules/queue
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
..
bytefifo.go
helper.go Add more linters to improve code readability (#19989) 2022-06-20 12:02:49 +02:00
manager.go
queue.go
queue_bytefifo.go Add more linters to improve code readability (#19989) 2022-06-20 12:02:49 +02:00
queue_channel.go Add Goroutine stack inspector to admin/monitor (#19207) 2022-03-31 19:01:43 +02:00
queue_channel_test.go Prevent intermittent NPE in queue tests (#19301) 2022-04-02 15:59:04 +08:00
queue_disk.go
queue_disk_channel.go Add more linters to improve code readability (#19989) 2022-06-20 12:02:49 +02:00
queue_disk_channel_test.go test: use T.TempDir to create temporary test directory (#21043) 2022-09-04 16:14:53 +01:00
queue_disk_test.go test: use T.TempDir to create temporary test directory (#21043) 2022-09-04 16:14:53 +01:00
queue_redis.go
queue_test.go
queue_wrapped.go
setting.go
unique_queue.go
unique_queue_channel.go Add Goroutine stack inspector to admin/monitor (#19207) 2022-03-31 19:01:43 +02:00
unique_queue_channel_test.go Add Goroutine stack inspector to admin/monitor (#19207) 2022-03-31 19:01:43 +02:00
unique_queue_disk.go
unique_queue_disk_channel.go Add more linters to improve code readability (#19989) 2022-06-20 12:02:49 +02:00
unique_queue_redis.go
unique_queue_wrapped.go
workerpool.go Fix 64-bit atomic operations on 32-bit machines (#19531) 2022-04-27 10:32:04 -05:00