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.
This commit is contained in:
parent
5dbf376860
commit
c19baa10f8
@ -822,9 +822,7 @@ func TestMagicNames(t *testing.T) {
|
|||||||
|
|
||||||
// Test that chmod works correctly
|
// Test that chmod works correctly
|
||||||
func TestChmod(t *testing.T) {
|
func TestChmod(t *testing.T) {
|
||||||
// Note: t.Name() is not available before in Go 1.8
|
path := test_helpers.DefaultPlainDir + "/" + t.Name()
|
||||||
tName := "TestChmod"
|
|
||||||
path := test_helpers.DefaultPlainDir + "/" + tName
|
|
||||||
file, err := os.Create(path)
|
file, err := os.Create(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -854,9 +852,7 @@ func TestChmod(t *testing.T) {
|
|||||||
|
|
||||||
// Test that access(2) works correctly
|
// Test that access(2) works correctly
|
||||||
func TestAccess(t *testing.T) {
|
func TestAccess(t *testing.T) {
|
||||||
// Note: t.Name() is not available before in Go 1.8
|
path := test_helpers.DefaultPlainDir + "/" + t.Name()
|
||||||
tName := "TestAccess"
|
|
||||||
path := test_helpers.DefaultPlainDir + "/" + tName
|
|
||||||
file, err := os.Create(path)
|
file, err := os.Create(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -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
|
// all directories in the path with O_RDONLY. Now it uses O_PATH, which only needs
|
||||||
// the executable bit.
|
// the executable bit.
|
||||||
func Test0100Dir(t *testing.T) {
|
func Test0100Dir(t *testing.T) {
|
||||||
// Note: t.Name() is not available before in Go 1.8
|
dir := dirA + "/" + t.Name()
|
||||||
tName := "Test0100Dir"
|
|
||||||
dir := dirA + "/" + tName
|
|
||||||
err := os.Mkdir(dir, 0700)
|
err := os.Mkdir(dir, 0700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -242,7 +240,7 @@ func Test0100Dir(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileReverse := dirC + "/" + tName + "/hello"
|
fileReverse := dirC + "/" + t.Name() + "/hello"
|
||||||
fd, err := os.Open(fileReverse)
|
fd, err := os.Open(fileReverse)
|
||||||
// Make sure the dir can be removed after the test is done
|
// Make sure the dir can be removed after the test is done
|
||||||
os.Chmod(dir, 0700)
|
os.Chmod(dir, 0700)
|
||||||
|
@ -125,7 +125,11 @@ func ResetTmpDir(createDirIV bool) {
|
|||||||
//
|
//
|
||||||
// It returns cipherdir without a trailing slash.
|
// It returns cipherdir without a trailing slash.
|
||||||
func InitFS(t *testing.T, extraArgs ...string) string {
|
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 err != nil {
|
||||||
if t != nil {
|
if t != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user