MCPcopy
hub / github.com/syncthing/syncthing / TestSetPlatformData

Function TestSetPlatformData

lib/model/folder_test.go:148–185  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func 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}

Callers

nothing calls this directly

Calls 6

CreateMethod · 0.95
setPlatformDataMethod · 0.95
StringFunction · 0.92
FatalMethod · 0.80
CloseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected