feat: Add local_target variable and tests

This commit is contained in:
ge
2022-05-14 04:55:36 +03:00
parent d07ff8ca43
commit 0d355c468b
4 changed files with 30 additions and 5 deletions

2
tests/files/basic.plan Normal file
View File

@ -0,0 +1,2 @@
sources=('file:/home/user')
targets=('file:/var/backup')

View File

@ -0,0 +1,7 @@
sources=('file:/home/user')
targets=(
'file:///home/backups'
'file:/var/backup'
'file:/backups'
's3://bucket'
)

View File

@ -39,7 +39,7 @@ setup() {
assert_output --partial 'Error: targets array is not set'
}
@test "No targets with file URI scheme" {
@test "No targets with 'file' URI scheme" {
. script.sh
run source_script $DIR/files/no_file_target.plan
assert_output --partial "Error: 'file' scheme is not set in targets. You must provide one or more targets with 'file' scheme."
@ -56,3 +56,15 @@ setup() {
run source_script $DIR/files/unsupported_target_scheme.plan
assert_output --partial 'Error: Unsupported URI scheme: scp'
}
@test "Set local target" {
. script.sh
source_script $DIR/files/basic.plan
[ "$local_target" == 'file:/var/backup' ]
}
@test "Set local target from multiple 'file' targets" {
. script.sh
source_script $DIR/files/multiple_file_targets.plan
[ "$local_target" == 'file:///home/backups' ]
}