mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-08-06 08:13:01 +02:00
Monitor backups with Cronhub hook integration. Fix Healthchecks/Cronitor hooks to respect dry run.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from flexmock import flexmock
|
||||
|
||||
from borgmatic.hooks import cronhub as module
|
||||
|
||||
|
||||
def test_ping_cronhub_hits_ping_url_with_start_state():
|
||||
ping_url = 'https://example.com/start/abcdef'
|
||||
state = 'bork'
|
||||
flexmock(module.requests).should_receive('get').with_args('https://example.com/bork/abcdef')
|
||||
|
||||
module.ping_cronhub(ping_url, 'config.yaml', dry_run=False, state=state)
|
||||
|
||||
|
||||
def test_ping_cronhub_hits_ping_url_with_ping_state():
|
||||
ping_url = 'https://example.com/ping/abcdef'
|
||||
state = 'bork'
|
||||
flexmock(module.requests).should_receive('get').with_args('https://example.com/bork/abcdef')
|
||||
|
||||
module.ping_cronhub(ping_url, 'config.yaml', dry_run=False, state=state)
|
||||
|
||||
|
||||
def test_ping_cronhub_without_ping_url_does_not_raise():
|
||||
flexmock(module.requests).should_receive('get').never()
|
||||
|
||||
module.ping_cronhub(ping_url=None, config_filename='config.yaml', dry_run=False, state='oops')
|
||||
|
||||
|
||||
def test_ping_cronhub_dry_run_does_not_hit_ping_url():
|
||||
ping_url = 'https://example.com'
|
||||
flexmock(module.requests).should_receive('get').never()
|
||||
|
||||
module.ping_cronhub(ping_url, 'config.yaml', dry_run=True, state='yay')
|
||||
@@ -15,3 +15,10 @@ def test_ping_cronitor_without_ping_url_does_not_raise():
|
||||
flexmock(module.requests).should_receive('get').never()
|
||||
|
||||
module.ping_cronitor(ping_url=None, config_filename='config.yaml', dry_run=False, append='oops')
|
||||
|
||||
|
||||
def test_ping_cronitor_dry_run_does_not_hit_ping_url():
|
||||
ping_url = 'https://example.com'
|
||||
flexmock(module.requests).should_receive('get').never()
|
||||
|
||||
module.ping_cronitor(ping_url, 'config.yaml', dry_run=True, append='yay')
|
||||
|
||||
@@ -31,3 +31,10 @@ def test_ping_healthchecks_hits_ping_url_with_append():
|
||||
flexmock(module.requests).should_receive('get').with_args('{}/{}'.format(ping_url, append))
|
||||
|
||||
module.ping_healthchecks(ping_url, 'config.yaml', dry_run=False, append=append)
|
||||
|
||||
|
||||
def test_ping_healthchecks_dry_run_does_not_hit_ping_url():
|
||||
ping_url = 'https://example.com'
|
||||
flexmock(module.requests).should_receive('get').never()
|
||||
|
||||
module.ping_healthchecks(ping_url, 'config.yaml', dry_run=True)
|
||||
|
||||
Reference in New Issue
Block a user