MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestFind

Function TestFind

internal/devconfig/config_test.go:98–189  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestFind(t *testing.T) {
99 t.Run("StartInSameDir", func(t *testing.T) {
100 root, child, _ := mkNestedDirs(t)
101 if _, err := Init(root); err != nil {
102 t.Fatalf("Init(%q) error: %v", root, err)
103 }
104 if _, err := Init(child); err != nil {
105 t.Fatalf("Init(%q) error: %v", child, err)
106 }
107
108 cfg, err := Find(child)
109 if err != nil {
110 t.Fatalf("Find(%q) error: %v", child, err)
111 }
112 gotDir := filepath.Dir(cfg.Root.AbsRootPath)
113 if gotDir != child {
114 t.Errorf("filepath.Dir(cfg.Root.AbsRootPath) = %q, want %q", gotDir, child)
115 }
116 })
117 t.Run("StartInChildDir", func(t *testing.T) {
118 root, child, _ := mkNestedDirs(t)
119 if _, err := Init(root); err != nil {
120 t.Fatalf("Init(%q) error: %v", root, err)
121 }
122
123 cfg, err := Find(child)
124 if err != nil {
125 t.Fatalf("Find(%q) error: %v", child, err)
126 }
127 gotDir := filepath.Dir(cfg.Root.AbsRootPath)
128 if gotDir != root {
129 t.Errorf("filepath.Dir(cfg.Root.AbsRootPath) = %q, want %q", gotDir, root)
130 }
131 })
132 t.Run("StartInNestedChildDir", func(t *testing.T) {
133 root, child, nested := mkNestedDirs(t)
134 if _, err := Init(root); err != nil {
135 t.Fatalf("Init(%q) error: %v", root, err)
136 }
137 if _, err := Init(child); err != nil {
138 t.Fatalf("Init(%q) error: %v", child, err)
139 }
140
141 cfg, err := Find(nested)
142 if err != nil {
143 t.Fatalf("Find(%q) error: %v", nested, err)
144 }
145 gotDir := filepath.Dir(cfg.Root.AbsRootPath)
146 if gotDir != child {
147 t.Errorf("filepath.Dir(cfg.Root.AbsRootPath) = %q, want %q", gotDir, child)
148 }
149 })
150 t.Run("IgnoreDirsWithMatchingName", func(t *testing.T) {
151 root, child, _ := mkNestedDirs(t)
152 if _, err := Init(root); err != nil {
153 t.Fatalf("Init(%q) error: %v", root, err)
154 }
155

Callers

nothing calls this directly

Calls 5

mkNestedDirsFunction · 0.85
InitFunction · 0.85
FindFunction · 0.85
IsMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected