fix: Add tests for file:///path/with/may/sub/dir/s
This commit is contained in:
		@@ -1,2 +1,2 @@
 | 
			
		||||
sources=('file:/home/user')
 | 
			
		||||
targets=('file:/var/backup')
 | 
			
		||||
targets=('file:/etc/lvm/backup')
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
sources=('file:/home/user')
 | 
			
		||||
targets=(
 | 
			
		||||
    'file:///home/backups'
 | 
			
		||||
    'file:///etc/lvm/backup'
 | 
			
		||||
    'file:/var/backup'
 | 
			
		||||
    'file:/backups'
 | 
			
		||||
    's3://bucket'
 | 
			
		||||
 
 | 
			
		||||
@@ -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" == '' ]
 | 
			
		||||
 
 | 
			
		||||
@@ -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' ]
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user