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') sources=('file:/home/user')
targets=('file:/var/backup') targets=('file:/etc/lvm/backup')

View File

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

View File

@ -54,6 +54,19 @@ setup() {
[ "$fragment" == '' ] [ "$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" { @test "sqlite:///path" {
. uri.sh . uri.sh
parse_uri 'sqlite:///path' parse_uri 'sqlite:///path'
@ -80,13 +93,13 @@ setup() {
[ "$fragment" == '' ] [ "$fragment" == '' ]
} }
@test "s3://host/path" { @test "s3://bucket/backups" {
. uri.sh . uri.sh
parse_uri 's3://host/path' parse_uri 's3://bucket/backups'
[ "$scheme" == 's3' ] [ "$scheme" == 's3' ]
[ "$hostname" == 'host' ] [ "$hostname" == 'bucket' ]
[ "$port" == '' ] [ "$port" == '' ]
[ "$path" == '/path' ] [ "$path" == '/backups' ]
[ "$username" == '' ] [ "$username" == '' ]
[ "$password" == '' ] [ "$password" == '' ]
[ "$query" == '' ] [ "$query" == '' ]

View File

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