1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/pkg/piperutils
Eng Zer Jun 0f4e30e9db
test: use T.TempDir to create temporary test directory (#3721)
This commit replaces `ioutil.TempDir` 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 `ioutil.TempDir`
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>

Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
2022-07-12 15:19:12 +02:00
..
testdata Fortify implementation in golang (#1428) 2020-05-25 19:48:59 +02:00
credentials_test.go feat(npm): allow to publish artifact to registry (#2871) 2021-07-15 14:46:04 +02:00
credentials.go feat(npm): allow to publish artifact to registry (#2871) 2021-07-15 14:46:04 +02:00
fileUtils_test.go test: use T.TempDir to create temporary test directory (#3721) 2022-07-12 15:19:12 +02:00
FileUtils.go feat(cnbBuild): cache buildpacks during multi-image build (#3635) 2022-03-30 13:58:16 +02:00
ioUtils_test.go test: use T.TempDir to create temporary test directory (#3721) 2022-07-12 15:19:12 +02:00
ioUtils.go Replace io.Copy (#2934) 2021-06-23 14:41:52 +02:00
projectStructure_test.go Add functions to infer build tool (#1210) 2020-02-23 16:54:50 +01:00
projectStructure.go Add functions to infer build tool (#1210) 2020-02-23 16:54:50 +01:00
slices_test.go feat(detectExecuteScan): SARIF export and GH issue creation (#3637) 2022-03-17 15:32:48 +01:00
slices.go feat(detectExecuteScan): SARIF export and GH issue creation (#3637) 2022-03-17 15:32:48 +01:00
stepResults_test.go test: use T.TempDir to create temporary test directory (#3721) 2022-07-12 15:19:12 +02:00
stepResults.go fix: improve stepResults handling (#1425) 2020-04-20 16:18:49 +02:00
strings_test.go replace depreacted strings.Title function (#3786) 2022-05-20 18:50:03 +02:00
strings.go replace depreacted strings.Title function (#3786) 2022-05-20 18:50:03 +02:00
templateUtils_test.go Fortify implementation in golang (#1428) 2020-05-25 19:48:59 +02:00
templateUtils.go fix(typo): found by misspell (#2064) 2020-09-24 07:41:06 +02:00