syncthing/lib/osutil
Eng Zer Jun bc27aa12cd
all: use T.TempDir to create temporary test directory (#8280)
This commit replaces `os.MkdirTemp` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `os.MkdirTemp`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-04-15 07:44:06 +04:00
..
atomic_test.go all: use T.TempDir to create temporary test directory (#8280) 2022-04-15 07:44:06 +04:00
atomic_unix_test.go all: Remove usage of deprecated io/ioutil (#7971) 2021-11-22 08:59:47 +01:00
atomic.go all: Remove usage of deprecated io/ioutil (#7971) 2021-11-22 08:59:47 +01:00
filenames_darwin.go all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
filenames_unix.go all: Update build constraints to Go 1.17 style (#7894) 2021-08-17 10:10:41 +02:00
filenames_windows.go all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
hidden_unix.go all: Update build constraints to Go 1.17 style (#7894) 2021-08-17 10:10:41 +02:00
hidden_windows.go all: Update build constraints to Go 1.17 style (#7894) 2021-08-17 10:10:41 +02:00
lan.go all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
lowprio_linux.go all: Update build constraints to Go 1.17 style (#7894) 2021-08-17 10:10:41 +02:00
lowprio_unix.go all: Update build constraints to Go 1.17 style (#7894) 2021-08-17 10:10:41 +02:00
lowprio_windows.go lib/osutil: Use x/sys/windows for SetLowPriority 2021-11-27 15:35:07 +01:00
osutil_test.go all: use T.TempDir to create temporary test directory (#8280) 2022-04-15 07:44:06 +04:00
osutil.go lib/fs: Properly handle case insensitive systems (fixes #1787, fixes #2739, fixes #5708) 2020-07-28 11:15:11 +02:00
ping.go lib/dialer: Preserve nilness in error handling (fixes #6368) (#6369) 2020-02-26 13:16:18 +01:00
replacingwriter_test.go all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
replacingwriter.go lib/config, lib/ignore: Write Windows line endings (fixes #7115) (#8052) 2021-11-22 09:38:24 +01:00
rlimit_unix.go all: Update build constraints to Go 1.17 style (#7894) 2021-08-17 10:10:41 +02:00
rlimit_windows.go all: Update build constraints to Go 1.17 style (#7894) 2021-08-17 10:10:41 +02:00
tempfile.go all: Convert folders to use filesystem abstraction 2017-08-19 14:36:56 +00:00
traversessymlink_test.go all: use T.TempDir to create temporary test directory (#8280) 2022-04-15 07:44:06 +04:00
traversessymlink.go lib: Prevent using protocol method with native path (fixes #7557) (#7563) 2021-04-11 15:29:43 +02:00