MCPcopy
hub / github.com/syncthing/syncthing / TestIsEncryptedParent

Function TestIsEncryptedParent

lib/protocol/encryption_test.go:230–256  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

228}
229
230func TestIsEncryptedParent(t *testing.T) {
231 comp := rand.String(maxPathComponent)
232 cases := []struct {
233 path string
234 is bool
235 }{
236 {"", false},
237 {".", false},
238 {"/", false},
239 {"12" + encryptedDirExtension, false},
240 {"1" + encryptedDirExtension, true},
241 {"1" + encryptedDirExtension + "/b", false},
242 {"1" + encryptedDirExtension + "/bc", true},
243 {"1" + encryptedDirExtension + "/bcd", false},
244 {"1" + encryptedDirExtension + "/bc/foo", false},
245 {"1.12/22", false},
246 {"1" + encryptedDirExtension + "/bc/" + comp, true},
247 {"1" + encryptedDirExtension + "/bc/" + comp + "/" + comp, true},
248 {"1" + encryptedDirExtension + "/bc/" + comp + "a", false},
249 {"1" + encryptedDirExtension + "/bc/" + comp + "/a/" + comp, false},
250 }
251 for _, tc := range cases {
252 if res := IsEncryptedParent(strings.Split(tc.path, "/")); res != tc.is {
253 t.Errorf("%v: got %v, expected %v", tc.path, res, tc.is)
254 }
255 }
256}

Callers

nothing calls this directly

Calls 2

StringFunction · 0.92
IsEncryptedParentFunction · 0.85

Tested by

no test coverage detected