(t *testing.T)
| 1871 | } |
| 1872 | |
| 1873 | func TestTreeFindEntryDuplicates(t *testing.T) { |
| 1874 | t.Parallel() |
| 1875 | |
| 1876 | hashA := bytes.Repeat([]byte{0xAA}, 20) |
| 1877 | hashB := bytes.Repeat([]byte{0xBB}, 20) |
| 1878 | hashC := bytes.Repeat([]byte{0xCC}, 20) |
| 1879 | |
| 1880 | cases := []struct { |
| 1881 | name string |
| 1882 | body []byte |
| 1883 | lookup string |
| 1884 | wantHash []byte |
| 1885 | wantMode filemode.FileMode |
| 1886 | wantCount int |
| 1887 | }{ |
| 1888 | { |
| 1889 | name: "two regular files with same name", |
| 1890 | body: encodeRawTreeEntries( |
| 1891 | rawTreeEntry{"100644", "foo", hashA}, |
| 1892 | rawTreeEntry{"100644", "foo", hashB}, |
| 1893 | ), |
| 1894 | lookup: "foo", |
| 1895 | wantHash: hashA, |
| 1896 | wantMode: filemode.Regular, |
| 1897 | wantCount: 2, |
| 1898 | }, |
| 1899 | { |
| 1900 | name: "triplicate regular file", |
| 1901 | body: encodeRawTreeEntries( |
| 1902 | rawTreeEntry{"100644", "foo", hashA}, |
| 1903 | rawTreeEntry{"100644", "foo", hashB}, |
| 1904 | rawTreeEntry{"100644", "foo", hashC}, |
| 1905 | ), |
| 1906 | lookup: "foo", |
| 1907 | wantHash: hashA, |
| 1908 | wantMode: filemode.Regular, |
| 1909 | wantCount: 3, |
| 1910 | }, |
| 1911 | { |
| 1912 | name: "file shadows later directory of same name", |
| 1913 | body: encodeRawTreeEntries( |
| 1914 | rawTreeEntry{"100644", "foo", hashA}, |
| 1915 | rawTreeEntry{"40000", "foo", hashB}, |
| 1916 | ), |
| 1917 | lookup: "foo", |
| 1918 | wantHash: hashA, |
| 1919 | wantMode: filemode.Regular, |
| 1920 | wantCount: 2, |
| 1921 | }, |
| 1922 | { |
| 1923 | name: "directory shadows later file of same name", |
| 1924 | body: encodeRawTreeEntries( |
| 1925 | rawTreeEntry{"40000", "foo", hashA}, |
| 1926 | rawTreeEntry{"100644", "foo", hashB}, |
| 1927 | ), |
| 1928 | lookup: "foo", |
| 1929 | wantHash: hashA, |
| 1930 | wantMode: filemode.Dir, |
nothing calls this directly
no test coverage detected
searching dependent graphs…