MCPcopy
hub / github.com/wagoodman/dive / TestStringBetween

Function TestStringBetween

dive/filetree/file_tree_test.go:88–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func TestStringBetween(t *testing.T) {
89 tree := NewFileTree()
90 _, _, err := tree.AddPath("/etc/nginx/nginx.conf", FileInfo{})
91 if err != nil {
92 t.Errorf("could not setup test: %v", err)
93 }
94 _, _, err = tree.AddPath("/etc/nginx/public", FileInfo{})
95 if err != nil {
96 t.Errorf("could not setup test: %v", err)
97 }
98 _, _, err = tree.AddPath("/var/run/systemd", FileInfo{})
99 if err != nil {
100 t.Errorf("could not setup test: %v", err)
101 }
102 _, _, err = tree.AddPath("/var/run/bashful", FileInfo{})
103 if err != nil {
104 t.Errorf("could not setup test: %v", err)
105 }
106 _, _, err = tree.AddPath("/tmp", FileInfo{})
107 if err != nil {
108 t.Errorf("could not setup test: %v", err)
109 }
110 _, _, err = tree.AddPath("/tmp/nonsense", FileInfo{})
111 if err != nil {
112 t.Errorf("could not setup test: %v", err)
113 }
114
115 expected :=
116 `│ └── public
117├── tmp
118│ └── nonsense
119`
120 actual := tree.StringBetween(3, 5, false)
121
122 if expected != actual {
123 t.Errorf("Expected tree string:\n--->%s<---\nGot:\n--->%s<---", expected, actual)
124 }
125
126}
127
128func TestRejectPurelyRelativePath(t *testing.T) {
129 tree := NewFileTree()

Callers

nothing calls this directly

Calls 3

AddPathMethod · 0.95
StringBetweenMethod · 0.95
NewFileTreeFunction · 0.85

Tested by

no test coverage detected