From 2d18b2d7846b154fa48f113efb6a805ce546ecc6 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 28 Jan 2017 15:44:31 -0800 Subject: [PATCH] Start test templates. --- automated install/basic-install.sh | 9 +++++---- test/test_automated_install.py | 9 +++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 9fed0bca..003cd312 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -692,7 +692,7 @@ enable_service() { echo " done." } -update_pacakge_cache() { +update_package_cache() { #Running apt-get update/upgrade with minimal output can cause some issues with #requiring user input (e.g password for phpmyadmin see #218) @@ -701,8 +701,9 @@ update_pacakge_cache() { echo ":::" echo -n "::: Updating local cache of available packages..." - ${UPDATE_PKG_CACHE} &> /dev/null - echo " done!" + if ${UPDATE_PKG_CACHE}; then + echo " done!" + fi } notify_package_updates_available() { @@ -1127,7 +1128,7 @@ main() { fi # Update package cache - update_pacakge_cache + update_package_cache # Notify user of package availability notify_package_updates_available diff --git a/test/test_automated_install.py b/test/test_automated_install.py index f8e2ec3d..c502aef6 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -274,6 +274,15 @@ def test_installPiholeWeb_already_populated_no_errors(Pihole): assert 'index.js' in web_directory assert 'blockingpage.css' in web_directory +def test_update_package_cache_success_no_errors(Pihole): + ''' confirms package cache was updated without any errors''' + updateCache = Pihole.run(''' + source /opt/pihole/basic-install.sh + update_package_cache + ''') + assert 'Updating local cache of available packages...' in updateCache.stdout + assert 'done!' in updateCache.stdout + # Helper functions def mock_command(script, args, container): ''' Allows for setup of commands we don't really want to have to run for real in unit tests '''