mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
Merge pull request #1183 from pi-hole/tweak/update_cache_trap
Trap for package cache update failures.
This commit is contained in:
commit
314f7e7889
@ -698,7 +698,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)
|
||||
|
||||
@ -707,8 +707,11 @@ update_pacakge_cache() {
|
||||
|
||||
echo ":::"
|
||||
echo -n "::: Updating local cache of available packages..."
|
||||
${UPDATE_PKG_CACHE} &> /dev/null
|
||||
echo " done!"
|
||||
if eval ${UPDATE_PKG_CACHE} &> /dev/null; then
|
||||
echo " done!"
|
||||
else
|
||||
echo -n "\n!!! ERROR - Unable to update package cache. Please try \"${UPDATE_PKG_CACHE}\""
|
||||
fi
|
||||
}
|
||||
|
||||
notify_package_updates_available() {
|
||||
@ -1133,7 +1136,7 @@ main() {
|
||||
fi
|
||||
|
||||
# Update package cache
|
||||
update_pacakge_cache
|
||||
update_package_cache
|
||||
|
||||
# Notify user of package availability
|
||||
notify_package_updates_available
|
||||
|
@ -274,6 +274,29 @@ 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
|
||||
distro_check
|
||||
update_package_cache
|
||||
''')
|
||||
assert 'Updating local cache of available packages...' in updateCache.stdout
|
||||
assert 'ERROR' not in updateCache.stdout
|
||||
assert 'done!' in updateCache.stdout
|
||||
|
||||
def test_update_package_cache_failure_no_errors(Pihole):
|
||||
''' confirms package cache was not updated'''
|
||||
mock_command('apt-get', {'update':('', '1')}, Pihole)
|
||||
updateCache = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
update_package_cache
|
||||
''')
|
||||
assert 'Updating local cache of available packages...' in updateCache.stdout
|
||||
assert 'ERROR' in updateCache.stdout
|
||||
assert 'done!' not 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 '''
|
||||
|
Loading…
Reference in New Issue
Block a user