Skip to content

Commit

Permalink
tests: Add a test for --publish
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Faria <[email protected]>
  • Loading branch information
albertofaria committed Apr 15, 2024
1 parent 2a8c00c commit bc24617
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ run)
__skip() {
exit 0
}
__log() {
__small_log 36 \"\$@\"
}
TEMP_DIR=~/$label.temp
UTIL_DIR=~/$label.util
ENGINE=$engine
Expand Down
26 changes: 26 additions & 0 deletions tests/t/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-License-Identifier: GPL-2.0-or-later

image="${TEST_IMAGES[fedora]}"
user="${TEST_IMAGES_DEFAULT_USER[fedora]}"

__engine run \
--rm --detach \
--name publish \
--publish 127.0.0.1::8000 \
"$image" \
""

endpoint=$( __engine port publish | tee /dev/stderr | cut -d' ' -f3 )

__engine exec publish --as "$user"

__log 'Ensuring curl fails...'
! curl "$endpoint" 2>/dev/null

__engine exec publish --as "$user" python -m http.server &
trap '__engine stop publish' EXIT

sleep 3

__log 'Ensuring curl succeeds...'
[[ "$( curl "$endpoint" 2>/dev/null | head -1 )" == "<!DOCTYPE HTML>" ]]

0 comments on commit bc24617

Please sign in to comment.