Skip to content

Commit 755cc3a

Browse files
CyberShadowthewilsonator
authored andcommitted
ci(test/feat663-search): use local test registry instead of remote
- Start a local test registry server using test_registry.d - Add mock API response files for search queries - Use --skip-registry=all --registry=http://localhost:$PORT flags - Update .gitignore to allow test/*/api/ directories Fixes the test by not depending on external services.
1 parent 0030b9a commit 755cc3a

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ __dummy.html
4949
!/test/*/dub.settings.json
5050
!/test/*/source/
5151
!/test/*/src/
52+
!/test/*/api/
5253

5354
# Ignore coverage files
5455
cov/

test/feat663-search.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
#!/usr/bin/env bash
22

3-
. $(dirname "${BASH_SOURCE[0]}")/common.sh
3+
DIR=$(dirname "${BASH_SOURCE[0]}")
4+
5+
. "$DIR"/common.sh
6+
7+
# Test that search without arguments fails
48
if ${DUB} search 2>/dev/null; then
59
die $LINENO '`dub search` succeeded'
610
fi
7-
if ${DUB} search nonexistent123456789package 2>/dev/null; then
11+
12+
# Start the local test registry
13+
PORT=$(getRandomPort)
14+
15+
${DUB} build --single "$DIR"/test_registry.d
16+
"$DIR"/test_registry --folder="$DIR/feat663-search" --port=$PORT &
17+
PID=$!
18+
sleep 1
19+
trap 'kill $PID 2>/dev/null || true' exit
20+
21+
# Test that search for nonexistent package returns no matches
22+
if ${DUB} search nonexistent123456789package --skip-registry=all --registry=http://localhost:$PORT 2>/dev/null; then
823
die $LINENO '`dub search nonexistent123456789package` succeeded'
924
fi
10-
if ! OUTPUT=$(${DUB} search '"dub-registry"' -v 2>&1); then
25+
26+
# Test that search for "dub-registry" succeeds and returns results
27+
if ! OUTPUT=$(${DUB} search '"dub-registry"' -v --skip-registry=all --registry=http://localhost:$PORT 2>&1); then
1128
die $LINENO '`dub search "dub-registry"` failed' "$OUTPUT"
1229
fi
1330
if ! grep -q '^\s\sdub-registry (.*)\s'<<<"$OUTPUT"; then

test/feat663-search/.no_build

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"name": "dub-registry", "description": "A package registry for the D programming language", "version": "1.0.0"}]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

0 commit comments

Comments
 (0)