-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrename_test.go
87 lines (80 loc) · 1.87 KB
/
rename_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright 2017 The go-darwin Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin
package apfs
import (
"os"
"path/filepath"
"testing"
)
func TestRenamexNp(t *testing.T) {
type args struct {
src string
dst string
flag RENAME_FALG
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "simple",
args: args{
src: filepath.Join(mountPoint, "test-renamexnp.txt"),
dst: filepath.Join(mountPoint, "renamexnp.txt"),
flag: RENAME_FALG(0),
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fi, err := os.Create(tt.args.src)
if err != nil {
t.Fatal(err)
}
defer fi.Close()
err = RenamexNp(tt.args.src, tt.args.dst, tt.args.flag)
if (err != nil && fi.Name() == tt.args.dst) != tt.wantErr {
t.Errorf("RenamexNp(%v, %v, %v) error = %v, gotPath %v, wantErr %v", tt.args.src, tt.args.dst, tt.args.flag, err, fi.Name(), tt.wantErr)
}
})
}
}
func TestRenameatxNp(t *testing.T) {
type args struct {
src string
dst string
flag RENAME_FALG
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "simple",
args: args{
src: filepath.Join(mountPoint, "test-renameatxnp.txt"),
dst: filepath.Join(mountPoint, "renameatxnp.txt"),
flag: RENAME_FALG(0),
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fi, err := os.Create(tt.args.src)
if err != nil {
t.Fatal(err)
}
defer fi.Close()
err = RenameatxNp(tt.args.src, tt.args.dst, tt.args.flag)
if (err != nil && fi.Name() == tt.args.dst) != tt.wantErr {
t.Errorf("RenameatxNp(%v, %v, %v) error = %v, gotPath %v,, wantErr %v", tt.args.src, tt.args.dst, tt.args.flag, err, fi.Name(), tt.wantErr)
}
})
}
}