@@ -87,37 +87,52 @@ func TestDumpNode(t *testing.T) {
87
87
Linkname : "existingfile" ,
88
88
}
89
89
90
- var bufRegularFile , bufDirectory , bufSymlink , bufHardlink bytes.Buffer
90
+ missingParentEntry := & internal.FileMetadata {
91
+ Name : "foo/bar/baz/entry" ,
92
+ Type : internal .TypeReg ,
93
+ ModTime : & modTime ,
94
+ }
95
+
96
+ var bufRegularFile , bufDirectory , bufSymlink , bufHardlink , bufMissingParent bytes.Buffer
91
97
92
- err := dumpNode (& bufRegularFile , map [string ]int {}, map [string ]string {}, regularFileEntry )
98
+ added := map [string ]struct {}{"/" : {}}
99
+
100
+ err := dumpNode (& bufRegularFile , added , map [string ]int {}, map [string ]string {}, regularFileEntry )
93
101
if err != nil {
94
102
t .Errorf ("unexpected error for regular file: %v" , err )
95
103
}
96
104
97
- err = dumpNode (& bufDirectory , map [string ]int {}, map [string ]string {}, directoryEntry )
105
+ err = dumpNode (& bufDirectory , added , map [string ]int {}, map [string ]string {}, directoryEntry )
98
106
if err != nil {
99
107
t .Errorf ("unexpected error for directory: %v" , err )
100
108
}
101
109
102
- err = dumpNode (& bufSymlink , map [string ]int {}, map [string ]string {}, symlinkEntry )
110
+ err = dumpNode (& bufSymlink , added , map [string ]int {}, map [string ]string {}, symlinkEntry )
103
111
if err != nil {
104
112
t .Errorf ("unexpected error for symlink: %v" , err )
105
113
}
106
114
107
- err = dumpNode (& bufHardlink , map [string ]int {}, map [string ]string {}, hardlinkEntry )
115
+ err = dumpNode (& bufHardlink , added , map [string ]int {}, map [string ]string {}, hardlinkEntry )
108
116
if err != nil {
109
117
t .Errorf ("unexpected error for hardlink: %v" , err )
110
118
}
111
119
120
+ err = dumpNode (& bufMissingParent , added , map [string ]int {}, map [string ]string {}, missingParentEntry )
121
+ if err != nil {
122
+ t .Errorf ("unexpected error: %v" , err )
123
+ }
124
+
112
125
expectedRegularFile := "/example.txt 100 100000 1 1000 1000 0 1672531200.0 ab/cdef1234567890 - - user.key1=value1\n "
113
126
expectedDirectory := "/mydir 0 40000 1 1000 1000 0 1672531200.0 - - - user.key2=value2\n "
114
127
expectedSymlink := "/mysymlink 0 120000 1 0 0 0 1672531200.0 targetfile - -\n "
115
128
expectedHardlink := "/myhardlink 0 @100000 1 0 0 0 1672531200.0 /existingfile - -\n "
129
+ expectedActualMissingParent := "/foo 0 40755 1 0 0 0 0.0 - - -\n /foo/bar 0 40755 1 0 0 0 0.0 - - -\n /foo/bar/baz 0 40755 1 0 0 0 0.0 - - -\n /foo/bar/baz/entry 0 100000 1 0 0 0 1672531200.0 - - -\n "
116
130
117
131
actualRegularFile := bufRegularFile .String ()
118
132
actualDirectory := bufDirectory .String ()
119
133
actualSymlink := bufSymlink .String ()
120
134
actualHardlink := bufHardlink .String ()
135
+ actualMissingParent := bufMissingParent .String ()
121
136
122
137
if actualRegularFile != expectedRegularFile {
123
138
t .Errorf ("for regular file, got %q, want %q" , actualRegularFile , expectedRegularFile )
@@ -134,4 +149,7 @@ func TestDumpNode(t *testing.T) {
134
149
if actualHardlink != expectedHardlink {
135
150
t .Errorf ("for hardlink, got %q, want %q" , actualHardlink , expectedHardlink )
136
151
}
152
+ if actualMissingParent != expectedActualMissingParent {
153
+ t .Errorf ("for missing parent, got %q, want %q" , actualMissingParent , expectedActualMissingParent )
154
+ }
137
155
}
0 commit comments