diff options
author | Jakob Unterwurzacher | 2020-05-09 15:42:57 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2020-05-09 15:42:57 +0200 |
commit | c19baa10f8e8365ed9e3212a003a6b8f31f0320a (patch) | |
tree | db21d3e3ce534742e03c3235614ae5ee8b0a7251 | |
parent | 5dbf376860d51bac599064ad746ac94ade27c277 (diff) |
tests: use t.Name()
We did not use t.Name() as it was not available
before Go 1.8. Now the oldest Go version we support is
Go 1.11, so we can use it.
-rw-r--r-- | tests/matrix/matrix_test.go | 8 | ||||
-rw-r--r-- | tests/reverse/correctness_test.go | 6 | ||||
-rw-r--r-- | tests/test_helpers/helpers.go | 6 |
3 files changed, 9 insertions, 11 deletions
diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go index 2215ff6..6472aaa 100644 --- a/tests/matrix/matrix_test.go +++ b/tests/matrix/matrix_test.go @@ -822,9 +822,7 @@ func TestMagicNames(t *testing.T) { // Test that chmod works correctly func TestChmod(t *testing.T) { - // Note: t.Name() is not available before in Go 1.8 - tName := "TestChmod" - path := test_helpers.DefaultPlainDir + "/" + tName + path := test_helpers.DefaultPlainDir + "/" + t.Name() file, err := os.Create(path) if err != nil { t.Fatal(err) @@ -854,9 +852,7 @@ func TestChmod(t *testing.T) { // Test that access(2) works correctly func TestAccess(t *testing.T) { - // Note: t.Name() is not available before in Go 1.8 - tName := "TestAccess" - path := test_helpers.DefaultPlainDir + "/" + tName + path := test_helpers.DefaultPlainDir + "/" + t.Name() file, err := os.Create(path) if err != nil { t.Fatal(err) diff --git a/tests/reverse/correctness_test.go b/tests/reverse/correctness_test.go index 67edeb6..206bebd 100644 --- a/tests/reverse/correctness_test.go +++ b/tests/reverse/correctness_test.go @@ -225,9 +225,7 @@ func TestTooLongSymlink(t *testing.T) { // all directories in the path with O_RDONLY. Now it uses O_PATH, which only needs // the executable bit. func Test0100Dir(t *testing.T) { - // Note: t.Name() is not available before in Go 1.8 - tName := "Test0100Dir" - dir := dirA + "/" + tName + dir := dirA + "/" + t.Name() err := os.Mkdir(dir, 0700) if err != nil { t.Fatal(err) @@ -242,7 +240,7 @@ func Test0100Dir(t *testing.T) { t.Fatal(err) } - fileReverse := dirC + "/" + tName + "/hello" + fileReverse := dirC + "/" + t.Name() + "/hello" fd, err := os.Open(fileReverse) // Make sure the dir can be removed after the test is done os.Chmod(dir, 0700) diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go index bc5d275..93d34d6 100644 --- a/tests/test_helpers/helpers.go +++ b/tests/test_helpers/helpers.go @@ -125,7 +125,11 @@ func ResetTmpDir(createDirIV bool) { // // It returns cipherdir without a trailing slash. func InitFS(t *testing.T, extraArgs ...string) string { - dir, err := ioutil.TempDir(TmpDir, "") + prefix := "x." + if t != nil { + prefix = t.Name() + "." + } + dir, err := ioutil.TempDir(TmpDir, prefix) if err != nil { if t != nil { t.Fatal(err) |