Skip to content

Commit 22f555e

Browse files
committed
add new ghe-restore command line hostname test
1 parent 4675832 commit 22f555e

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

test/test-ghe-restore.sh

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,40 @@ begin_test "ghe-restore into unconfigured vm"
188188
)
189189
end_test
190190

191+
begin_test "ghe-restore with host arg and config value"
192+
(
193+
set -e
194+
rm -rf "$GHE_REMOTE_ROOT_DIR"
195+
setup_remote_metadata
196+
197+
# set as configured, enable maintenance mode and create required directories
198+
setup_maintenance_mode "configured"
199+
200+
# set restore host environ var (which we shouldn't see)
201+
GHE_RESTORE_HOST="broken.config.restore.host"
202+
export GHE_RESTORE_HOST
203+
204+
# set restore host config var (which we shouldn't see)
205+
GHE_BACKUP_CONFIG_TEMP="${GHE_BACKUP_CONFIG}.temp"
206+
cp "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_CONFIG_TEMP"
207+
echo 'GHE_RESTORE_HOST="broken.config.restore.host"' >> "$GHE_BACKUP_CONFIG_TEMP"
208+
GHE_BACKUP_CONFIG="$GHE_BACKUP_CONFIG_TEMP"
209+
export GHE_BACKUP_CONFIG
210+
211+
# run it
212+
output="$(ghe-restore -f localhost)" || false
213+
214+
# clean up the config file
215+
rm "$GHE_BACKUP_CONFIG_TEMP"
216+
217+
# verify host arg overrides configured restore host
218+
echo "$output" | grep -q 'Connect localhost:22 OK'
219+
220+
# Verify all the data we've restored is as expected
221+
verify_all_restored_data
222+
)
223+
end_test
224+
191225
begin_test "ghe-restore with host arg"
192226
(
193227
set -e
@@ -198,7 +232,7 @@ begin_test "ghe-restore with host arg"
198232
setup_maintenance_mode "configured"
199233

200234
# set restore host environ var
201-
GHE_RESTORE_HOST=127.0.0.1
235+
GHE_RESTORE_HOST="broken.environ.restore.host"
202236
export GHE_RESTORE_HOST
203237

204238
# run it

0 commit comments

Comments
 (0)