| 146 | } |
| 147 | |
| 148 | func TestSetPlatformData(t *testing.T) { |
| 149 | // Checks that setPlatformData runs without error when applied to a temp |
| 150 | // file, named differently than the given FileInfo. |
| 151 | |
| 152 | fs := fs.NewFilesystem(fs.FilesystemTypeFake, rand.String(32)) |
| 153 | if fd, err := fs.Create("file.tmp"); err != nil { |
| 154 | t.Fatal(err) |
| 155 | } else { |
| 156 | fd.Close() |
| 157 | } |
| 158 | |
| 159 | xattr := []protocol.Xattr{{Name: "user.foo", Value: []byte("bar")}} |
| 160 | fi := &protocol.FileInfo{ |
| 161 | Name: "should be ignored", |
| 162 | Permissions: 0o400, |
| 163 | ModifiedS: 1234567890, |
| 164 | Platform: protocol.PlatformData{ |
| 165 | Linux: &protocol.XattrData{Xattrs: xattr}, |
| 166 | Darwin: &protocol.XattrData{Xattrs: xattr}, |
| 167 | FreeBSD: &protocol.XattrData{Xattrs: xattr}, |
| 168 | NetBSD: &protocol.XattrData{Xattrs: xattr}, |
| 169 | }, |
| 170 | } |
| 171 | |
| 172 | // Minimum required to support setPlatformData |
| 173 | sr := &sendReceiveFolder{ |
| 174 | folder: &folder{ |
| 175 | FolderConfiguration: config.FolderConfiguration{ |
| 176 | SyncXattrs: true, |
| 177 | }, |
| 178 | mtimefs: fs, |
| 179 | }, |
| 180 | } |
| 181 | |
| 182 | if err := sr.setPlatformData(fi, "file.tmp"); err != nil { |
| 183 | t.Error(err) |
| 184 | } |
| 185 | } |