Skip to content

Commit e19f3b8

Browse files
committed
refactor(test): mock_clone no longer clones _from_ a github.com parent directory
Previously, when calls to, 'test_util.mock_add', and 'test_util.mock_link', etc. were done, they would assume that the remote origin was located at `"$BPM_ORIGIN_DIR/github.com/$pkg"`. This was only because The github.com part was hardcoded within mock_clone. Since the github.com subdirectory was only required within $BPM_PACKAGES_PATH (and not BPM_ORIGIN_DIR), the mock_clone function was refactored to removed this. Due to this change, there were many calls to 'test_util.mock_add', etc. that assumed the source directory structure included github.com. Those had to be refactored as well
1 parent 5872dba commit e19f3b8

File tree

8 files changed

+82
-107
lines changed

8 files changed

+82
-107
lines changed

tests/do-add.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ load 'util/init.sh'
3939
test_util.stub_command do-plumbing-link-man
4040

4141
test_util.create_package "$pkg"
42-
run do-add "$BPM_ORIGIN_DIR/$site/$pkg"
42+
run do-add "$BPM_ORIGIN_DIR/$pkg"
4343

4444
assert_failure
45-
assert_line -p "Identifier '$BPM_ORIGIN_DIR/$site/$pkg' is a directory, not a package"
45+
assert_line -p "Identifier '$BPM_ORIGIN_DIR/$pkg' is a directory, not a package"
4646
}
4747

4848
@test "executes install steps in right order" {

tests/do-link.bats

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ load 'util/init.sh'
5757
mkdir -p touch "$BPM_PACKAGES_PATH/local"
5858
touch "$BPM_PACKAGES_PATH/local/theta"
5959

60-
test_util.create_pkg_dir 'theta'
60+
test_util.create_package 'theta'
6161
mkdir 'theta'
6262

6363
run do-link "$BPM_ORIGIN_DIR/theta"
@@ -74,7 +74,7 @@ load 'util/init.sh'
7474

7575
local dir='package1'
7676

77-
test_util.create_pkg_dir "$dir"
77+
test_util.create_package "$dir"
7878

7979
run do-link "$BPM_ORIGIN_DIR/$dir"
8080

@@ -90,7 +90,7 @@ load 'util/init.sh'
9090

9191
local dir='package2'
9292

93-
test_util.create_pkg_dir "$dir"
93+
test_util.create_package "$dir"
9494

9595
# On macOS, the temporary folder '/var' is symlinked to '/private/var'
9696
# Since BATS appears to be using '/var' directly, we have to resolve the
@@ -117,8 +117,8 @@ load 'util/init.sh'
117117
local dir1='package2'
118118
local dir2='package3'
119119

120-
test_util.create_pkg_dir "$dir1"
121-
test_util.create_pkg_dir "$dir2"
120+
test_util.create_package "$dir1"
121+
test_util.create_package "$dir2"
122122

123123
local srcDir1="$(util.readlink "$BPM_ORIGIN_DIR/$dir1")"
124124
local srcDir2="$(util.readlink "$BPM_ORIGIN_DIR/$dir2")"
@@ -147,7 +147,7 @@ load 'util/init.sh'
147147

148148
local dir='package2'
149149

150-
test_util.create_pkg_dir "$dir"
150+
test_util.create_package "$dir"
151151

152152

153153
local srcDir="$(util.readlink "$BPM_ORIGIN_DIR/$dir")"
@@ -170,7 +170,7 @@ load 'util/init.sh'
170170

171171
local dir='package2'
172172

173-
test_util.create_pkg_dir "$dir"
173+
test_util.create_package "$dir"
174174

175175
run do-link --no-deps "$BPM_ORIGIN_DIR/$dir"
176176

@@ -186,7 +186,7 @@ load 'util/init.sh'
186186

187187
local dir='package2'
188188

189-
test_util.create_pkg_dir "$dir"
189+
test_util.create_package "$dir"
190190

191191
run do-link "$BPM_ORIGIN_DIR/$dir" --no-deps
192192

@@ -202,7 +202,7 @@ load 'util/init.sh'
202202

203203
local dir='package2'
204204

205-
test_util.create_pkg_dir "$dir"
205+
test_util.create_package "$dir"
206206

207207
cd "$BPM_ORIGIN_DIR/$dir"
208208
run do-link .
@@ -219,7 +219,7 @@ load 'util/init.sh'
219219

220220
local dir='package2'
221221

222-
test_util.create_pkg_dir "$dir"
222+
test_util.create_package "$dir"
223223

224224
cd "$BPM_ORIGIN_DIR/$dir"
225225
mkdir -p 'tango'
@@ -239,7 +239,7 @@ load 'util/init.sh'
239239

240240
local dir='package2'
241241

242-
test_util.create_pkg_dir "parent/$dir"
242+
test_util.create_package "parent/$dir"
243243

244244
cd "$BPM_ORIGIN_DIR/parent"
245245
run do-link "./$dir/.././$dir"

tests/do-list.bats

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ load 'util/init.sh'
3838
test_util.stub_command do-plumbing-link-man
3939

4040
test_util.create_package "$pkg"
41-
do-link "$BPM_ORIGIN_DIR/$site/$pkg"
41+
do-link "$BPM_ORIGIN_DIR/$pkg"
4242

4343
run do-list --simple
4444

@@ -93,7 +93,6 @@ $site/username2/p2
9393
local pkg='username/outdated'
9494

9595
mkdir -p "$BPM_PACKAGES_PATH/$site/$pkg"
96-
9796
run do-list
9897

9998
assert_failure

tests/do-plumbing-link-bins.bats

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ load 'util/init.sh'
99
test_util.setup_pkg "$pkg"; {
1010
:
1111
}; test_util.finish_pkg
12-
test_util.mock_clone "$site/$pkg"
12+
test_util.mock_clone "$pkg" "$site/$pkg"
1313

1414
run do-plumbing-link-bins "$site/$pkg"
1515

@@ -26,7 +26,7 @@ load 'util/init.sh'
2626
touch 'binn/exec1'
2727
touch 'binn/exec2.sh'
2828
}; test_util.finish_pkg
29-
test_util.mock_clone "$site/$pkg"
29+
test_util.mock_clone "$pkg" "$site/$pkg"
3030

3131
run do-plumbing-link-bins "$site/$pkg"
3232

@@ -48,7 +48,7 @@ load 'util/init.sh'
4848
mkdir 'ff'
4949
touch 'ff/exec3'
5050
}; test_util.finish_pkg
51-
test_util.mock_clone "$site/$pkg"
51+
test_util.mock_clone "$pkg" "$site/$pkg"
5252

5353
run do-plumbing-link-bins "$site/$pkg"
5454

@@ -68,7 +68,7 @@ load 'util/init.sh'
6868
touch 'weird_dir/exec1'
6969
touch 'weird_dir/exec2.sh'
7070
}; test_util.finish_pkg
71-
test_util.mock_clone "$site/$pkg"
71+
test_util.mock_clone "$pkg" "$site/$pkg"
7272

7373
run do-plumbing-link-bins "$site/$pkg"
7474

@@ -89,7 +89,7 @@ load 'util/init.sh'
8989
mkdir 'weird_dir'
9090
touch 'weird_dir/exec3'
9191
}; test_util.finish_pkg
92-
test_util.mock_clone "$site/$pkg"
92+
test_util.mock_clone "$pkg" "$site/$pkg"
9393

9494
run do-plumbing-link-bins "$site/$pkg"
9595

@@ -108,7 +108,7 @@ load 'util/init.sh'
108108
touch 'bin/exec1'
109109
touch 'bin/exec2.sh'
110110
}; test_util.finish_pkg
111-
test_util.mock_clone "$site/$pkg"
111+
test_util.mock_clone "$pkg" "$site/$pkg"
112112

113113
run do-plumbing-link-bins "$site/$pkg"
114114

@@ -126,7 +126,7 @@ load 'util/init.sh'
126126
touch 'bins/exec1'
127127
touch 'bins/exec2.sh'
128128
}; test_util.finish_pkg
129-
test_util.mock_clone "$site/$pkg"
129+
test_util.mock_clone "$pkg" "$site/$pkg"
130130

131131
run do-plumbing-link-bins "$site/$pkg"
132132

@@ -144,7 +144,7 @@ load 'util/init.sh'
144144
touch 'exec2.sh'
145145
chmod +x 'exec1' 'exec2.sh'
146146
}; test_util.finish_pkg
147-
test_util.mock_clone "$site/$pkg"
147+
test_util.mock_clone "$pkg" "$site/$pkg"
148148

149149
run do-plumbing-link-bins "$site/$pkg"
150150

@@ -161,7 +161,7 @@ load 'util/init.sh'
161161
touch 'exec1'
162162
touch 'exec2.sh'
163163
}; test_util.finish_pkg
164-
test_util.mock_clone "$site/$pkg"
164+
test_util.mock_clone "$pkg" "$site/$pkg"
165165

166166
run do-plumbing-link-bins "$site/$pkg"
167167

@@ -180,7 +180,7 @@ load 'util/init.sh'
180180
touch 'exec2'
181181
chmod +x 'exec2'
182182
}; test_util.finish_pkg
183-
test_util.mock_clone "$site/$pkg"
183+
test_util.mock_clone "$pkg" "$site/$pkg"
184184

185185
run do-plumbing-link-bins "$site/$pkg"
186186

@@ -199,7 +199,7 @@ load 'util/init.sh'
199199
touch 'bin/exec1'
200200
touch 'bin/exec2.sh'
201201
}; test_util.finish_pkg
202-
test_util.mock_clone "$site/$pkg"
202+
test_util.mock_clone "$pkg" "$site/$pkg"
203203

204204
run do-plumbing-link-bins "$site/$pkg"
205205

@@ -219,7 +219,7 @@ load 'util/init.sh'
219219
touch 'bin/exec1'
220220
touch 'bin/exec2.sh'
221221
}; test_util.finish_pkg
222-
test_util.mock_clone "$site/$pkg"
222+
test_util.mock_clone "$pkg" "$site/$pkg"
223223

224224
run do-plumbing-link-bins "$site/$pkg"
225225

@@ -239,7 +239,7 @@ load 'util/init.sh'
239239
touch 'bin/exec1'
240240
touch 'bin/exec2.sh'
241241
}; test_util.finish_pkg
242-
test_util.mock_clone "$site/$pkg"
242+
test_util.mock_clone "$pkg" "$site/$pkg"
243243

244244
run do-plumbing-link-bins "$site/$pkg"
245245

@@ -258,7 +258,7 @@ load 'util/init.sh'
258258
touch 'bin/exec1'
259259
touch 'bin/exec2.sh'
260260
}; test_util.finish_pkg
261-
test_util.mock_clone "$site/$pkg"
261+
test_util.mock_clone "$pkg" "$site/$pkg"
262262

263263
run do-plumbing-link-bins "$site/$pkg"
264264

@@ -277,7 +277,7 @@ load 'util/init.sh'
277277
touch 'bin/exec1'
278278
touch 'bin/exec2.sh'
279279
}; test_util.finish_pkg
280-
test_util.mock_clone "$site/$pkg"
280+
test_util.mock_clone "$pkg" "$site/$pkg"
281281

282282
run do-plumbing-link-bins "$site/$pkg"
283283

@@ -290,8 +290,8 @@ load 'util/init.sh'
290290
local dir='package'
291291
local dir2='username/package2'
292292

293-
test_util.create_pkg_dir "$dir"
294-
test_util.create_pkg_dir "$dir2"
293+
test_util.create_package "$dir"
294+
test_util.create_package "$dir2"
295295

296296
# implicit call to do-plumbing-link-bins
297297
run do-link "$BPM_ORIGIN_DIR/$dir" "$BPM_ORIGIN_DIR/$dir2"
@@ -311,7 +311,7 @@ load 'util/init.sh'
311311
mkdir 'dir'
312312
touch 'dir/.gitkeep'
313313
}; test_util.finish_pkg
314-
test_util.mock_clone "$site/$pkg"
314+
test_util.mock_clone "$pkg" "$site/$pkg"
315315

316316
run do-plumbing-link-bins "$site/$pkg"
317317

@@ -326,7 +326,7 @@ load 'util/init.sh'
326326
test_util.setup_pkg "$pkg"; {
327327
echo 'BINS="some_file"' > 'package.sh'
328328
}; test_util.finish_pkg
329-
test_util.mock_clone "$site/$pkg"
329+
test_util.mock_clone "$pkg" "$site/$pkg"
330330

331331
run do-plumbing-link-bins "$site/$pkg"
332332

@@ -341,7 +341,7 @@ load 'util/init.sh'
341341
echo 'binDirs = ["file"]' > 'bpm.toml'
342342
touch 'file'
343343
}; test_util.finish_pkg
344-
test_util.mock_clone "$site/$pkg"
344+
test_util.mock_clone "$pkg" "$site/$pkg"
345345

346346
run do-plumbing-link-bins "$site/$pkg"
347347

@@ -356,7 +356,7 @@ load 'util/init.sh'
356356
test_util.setup_pkg "$pkg"; {
357357
echo 'binDirs = ["dir"]' > 'bpm.toml'
358358
}; test_util.finish_pkg
359-
test_util.mock_clone "$site/$pkg"
359+
test_util.mock_clone "$pkg" "$site/$pkg"
360360

361361
run do-plumbing-link-bins "$site/$pkg"
362362

@@ -372,13 +372,13 @@ load 'util/init.sh'
372372
touch 'file2.bash'
373373
chmod +x 'file2.bash'
374374
}; test_util.finish_pkg
375-
test_util.mock_clone "$site/$pkg1"
375+
test_util.mock_clone "$pkg1" "$site/$pkg1"
376376

377377
test_util.setup_pkg "$pkg2"; {
378378
touch 'file2.bash'
379379
chmod +x 'file2.bash'
380380
}; test_util.finish_pkg
381-
test_util.mock_clone "$site/$pkg2"
381+
test_util.mock_clone "$pkg2" "$site/$pkg2"
382382

383383
do-plumbing-link-bins "$site/$pkg1"
384384
run do-plumbing-link-bins "$site/$pkg2"

0 commit comments

Comments
 (0)