fix: Add tests for file:///path/with/may/sub/dir/s

This commit is contained in:
ge 2022-05-14 21:10:05 +03:00
parent 63753a4fab
commit d2e882f1ec
4 changed files with 23 additions and 8 deletions

View File

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

View File

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

View File

@ -54,6 +54,19 @@ setup() {
[ "$fragment" == '' ]
}
@test "file:///path/with/may/sub/dir/s" {
. uri.sh
parse_uri 'file:///path/with/may/sub/dir/s'
[ "$scheme" == 'file' ]
[ "$hostname" == '' ]
[ "$port" == '' ]
[ "$path" == '/path/with/may/sub/dir/s' ]
[ "$username" == '' ]
[ "$password" == '' ]
[ "$query" == '' ]
[ "$fragment" == '' ]
}
@test "sqlite:///path" {
. uri.sh
parse_uri 'sqlite:///path'
@ -80,13 +93,13 @@ setup() {
[ "$fragment" == '' ]
}
@test "s3://host/path" {
@test "s3://bucket/backups" {
. uri.sh
parse_uri 's3://host/path'
parse_uri 's3://bucket/backups'
[ "$scheme" == 's3' ]
[ "$hostname" == 'host' ]
[ "$hostname" == 'bucket' ]
[ "$port" == '' ]
[ "$path" == '/path' ]
[ "$path" == '/backups' ]
[ "$username" == '' ]
[ "$password" == '' ]
[ "$query" == '' ]

View File

@ -59,12 +59,14 @@ setup() {
@test "Set __main_target" {
. source.sh
. uri.sh # for parse_uri()
source_script $DIR/files/basic.plan
[ "$__main_target" == 'file:/var/backup' ]
[ "$__main_target" == '/etc/lvm/backup' ]
}
@test "Set __main_target from multiple 'file' targets" {
. source.sh
. uri.sh # for parse_uri()
source_script $DIR/files/multiple_file_targets.plan
[ "$__main_target" == 'file:///home/backups' ]
[ "$__main_target" == '/etc/lvm/backup' ]
}