MCPcopy
hub / github.com/syncthing/syncthing / TestGlobalDirectoryTree

Function TestGlobalDirectoryTree

lib/model/model_test.go:1772–2038  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1770}
1771
1772func TestGlobalDirectoryTree(t *testing.T) {
1773 m, conn, fcfg := setupModelWithConnection(t)
1774 defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
1775
1776 var seq int64
1777 b := func(isfile bool, path ...string) protocol.FileInfo {
1778 typ := protocol.FileInfoTypeDirectory
1779 var blocks []protocol.BlockInfo
1780
1781 if isfile {
1782 typ = protocol.FileInfoTypeFile
1783 blocks = []protocol.BlockInfo{{Offset: 0x0, Size: 0xa, Hash: []uint8{0x2f, 0x72, 0xcc, 0x11, 0xa6, 0xfc, 0xd0, 0x27, 0x1e, 0xce, 0xf8, 0xc6, 0x10, 0x56, 0xee, 0x1e, 0xb1, 0x24, 0x3b, 0xe3, 0x80, 0x5b, 0xf9, 0xa9, 0xdf, 0x98, 0xf9, 0x2f, 0x76, 0x36, 0xb0, 0x5c}}}
1784 }
1785 seq++
1786 return protocol.FileInfo{
1787 Name: filepath.Join(path...),
1788 Type: typ,
1789 ModifiedS: 0x666,
1790 Blocks: blocks,
1791 Size: 0xa,
1792 Sequence: seq,
1793 }
1794 }
1795 f := func(name string) *TreeEntry {
1796 return &TreeEntry{
1797 Name: name,
1798 ModTime: time.Unix(0x666, 0),
1799 Size: 0xa,
1800 Type: protocol.FileInfoTypeFile.String(),
1801 }
1802 }
1803 d := func(name string, entries ...*TreeEntry) *TreeEntry {
1804 return &TreeEntry{
1805 Name: name,
1806 ModTime: time.Unix(0x666, 0),
1807 Size: 128,
1808 Type: protocol.FileInfoTypeDirectory.String(),
1809 Children: entries,
1810 }
1811 }
1812
1813 testdata := []protocol.FileInfo{
1814 b(false, "another"),
1815 b(false, "another", "directory"),
1816 b(true, "another", "directory", "afile"),
1817 b(false, "another", "directory", "with"),
1818 b(false, "another", "directory", "with", "a"),
1819 b(true, "another", "directory", "with", "a", "file"),
1820 b(true, "another", "directory", "with", "file"),
1821 b(true, "another", "file"),
1822
1823 b(false, "other"),
1824 b(false, "other", "rand"),
1825 b(false, "other", "random"),
1826 b(false, "other", "random", "dir"),
1827 b(false, "other", "random", "dirx"),
1828 b(false, "other", "randomx"),
1829

Callers

nothing calls this directly

Calls 9

setupModelWithConnectionFunction · 0.85
cleanupModelAndRemoveDirFunction · 0.85
mustFunction · 0.85
findByNameFunction · 0.85
FilesystemMethod · 0.80
URIMethod · 0.65
StringMethod · 0.65
IndexMethod · 0.65
GlobalDirectoryTreeMethod · 0.65

Tested by

no test coverage detected