(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestBuildTreeStructure(t *testing.T) { |
| 14 | files := []scanner.FileInfo{ |
| 15 | {Path: "main.go", Size: 100}, |
| 16 | {Path: "go.mod", Size: 50}, |
| 17 | {Path: "src/app.go", Size: 200}, |
| 18 | {Path: "src/util/helper.go", Size: 150}, |
| 19 | {Path: "test/main_test.go", Size: 80}, |
| 20 | } |
| 21 | |
| 22 | root := buildTreeStructure(files) |
| 23 | |
| 24 | // Root should have children |
| 25 | if len(root.children) == 0 { |
| 26 | t.Error("Root should have children") |
| 27 | } |
| 28 | |
| 29 | // Check main.go exists at root |
| 30 | if child, ok := root.children["main.go"]; !ok { |
| 31 | t.Error("Expected main.go at root") |
| 32 | } else if !child.isFile { |
| 33 | t.Error("main.go should be a file") |
| 34 | } |
| 35 | |
| 36 | // Check src directory exists |
| 37 | if child, ok := root.children["src"]; !ok { |
| 38 | t.Error("Expected src directory") |
| 39 | } else if child.isFile { |
| 40 | t.Error("src should be a directory") |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | func TestBuildTreeStructureEmpty(t *testing.T) { |
| 45 | files := []scanner.FileInfo{} |
nothing calls this directly
no test coverage detected