(t *testing.T)
| 130 | } |
| 131 | |
| 132 | func TestRenderCommitFileTree(t *testing.T) { |
| 133 | scenarios := []struct { |
| 134 | name string |
| 135 | root *filetree.FileNode |
| 136 | files []*models.CommitFile |
| 137 | collapsedPaths []string |
| 138 | showRootItem bool |
| 139 | expected []string |
| 140 | }{ |
| 141 | { |
| 142 | name: "nil node", |
| 143 | files: nil, |
| 144 | expected: []string{}, |
| 145 | }, |
| 146 | { |
| 147 | name: "leaf node", |
| 148 | files: []*models.CommitFile{ |
| 149 | {Path: "test", ChangeStatus: "A"}, |
| 150 | }, |
| 151 | showRootItem: true, |
| 152 | expected: []string{"A test"}, |
| 153 | }, |
| 154 | { |
| 155 | name: "big example", |
| 156 | files: []*models.CommitFile{ |
| 157 | {Path: "dir1/file2", ChangeStatus: "M"}, |
| 158 | {Path: "dir1/file3", ChangeStatus: "A"}, |
| 159 | {Path: "dir2/dir2/file3", ChangeStatus: "D"}, |
| 160 | {Path: "dir2/dir2/file4", ChangeStatus: "M"}, |
| 161 | {Path: "dir2/file5", ChangeStatus: "M"}, |
| 162 | {Path: "file1", ChangeStatus: "M"}, |
| 163 | }, |
| 164 | showRootItem: true, |
| 165 | expected: toStringSlice( |
| 166 | ` |
| 167 | ▼ / |
| 168 | ▶ dir1 |
| 169 | ▼ dir2 |
| 170 | ▼ dir2 |
| 171 | D file3 |
| 172 | M file4 |
| 173 | M file5 |
| 174 | M file1 |
| 175 | `, |
| 176 | ), |
| 177 | collapsedPaths: []string{"./dir1"}, |
| 178 | }, |
| 179 | { |
| 180 | name: "big example without root item", |
| 181 | files: []*models.CommitFile{ |
| 182 | {Path: "dir1/file2", ChangeStatus: "M"}, |
| 183 | {Path: "dir1/file3", ChangeStatus: "A"}, |
| 184 | {Path: "dir2/dir2/file3", ChangeStatus: "D"}, |
| 185 | {Path: "dir2/dir2/file4", ChangeStatus: "M"}, |
| 186 | {Path: "dir2/file5", ChangeStatus: "M"}, |
| 187 | {Path: "file1", ChangeStatus: "M"}, |
| 188 | }, |
| 189 | showRootItem: false, |
nothing calls this directly
no test coverage detected