124 lines
2.7 KiB
Bash
124 lines
2.7 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
setup_file(){
|
|
load "$PWD/tests/integration/helpers/common"
|
|
_common_setup
|
|
_add_server
|
|
_new_app
|
|
}
|
|
|
|
teardown_file(){
|
|
_rm_app
|
|
_rm_server
|
|
}
|
|
|
|
setup(){
|
|
load "$PWD/tests/integration/helpers/common"
|
|
_common_setup
|
|
}
|
|
|
|
@test "validate app argument" {
|
|
run $ABRA app cp
|
|
assert_failure
|
|
assert_output --partial 'no app provided'
|
|
|
|
run $ABRA app cp DOESNTEXIST
|
|
assert_failure
|
|
assert_output --partial 'cannot find app'
|
|
}
|
|
|
|
@test "error if missing src/dest arguments" {
|
|
run $ABRA app cp "$TEST_APP_DOMAIN"
|
|
assert_failure
|
|
assert_output --partial 'missing <src> argument'
|
|
|
|
run $ABRA app cp "$TEST_APP_DOMAIN" myfile.txt
|
|
assert_failure
|
|
assert_output --partial 'missing <dest> argument'
|
|
}
|
|
|
|
@test "either src/dest has correct syntax" {
|
|
run $ABRA app cp "$TEST_APP_DOMAIN" myfile.txt app
|
|
assert_failure
|
|
assert_output --partial 'arguments must take $SERVICE:$PATH form'
|
|
|
|
run $ABRA app cp "$TEST_APP_DOMAIN" app .
|
|
assert_failure
|
|
assert_output --partial 'arguments must take $SERVICE:$PATH form'
|
|
}
|
|
|
|
@test "detect 'coming FROM' syntax" {
|
|
run $ABRA app cp "$TEST_APP_DOMAIN" app:/myfile.txt . --debug
|
|
assert_failure
|
|
assert_output --partial 'coming FROM the container'
|
|
}
|
|
|
|
@test "detect 'going TO' syntax" {
|
|
run $ABRA app cp "$TEST_APP_DOMAIN" myfile.txt app:/somewhere --debug
|
|
assert_failure
|
|
assert_output --partial 'going TO the container'
|
|
}
|
|
|
|
@test "error if local file missing" {
|
|
run $ABRA app cp "$TEST_APP_DOMAIN" myfile.txt app:/somewhere
|
|
assert_failure
|
|
assert_output --partial 'myfile.txt does not exist locally?'
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "error if service doesn't exist" {
|
|
_deploy_app
|
|
|
|
run bash -c "echo foo >> $BATS_TMPDIR/myfile.txt"
|
|
assert_success
|
|
|
|
run $ABRA app cp "$TEST_APP_DOMAIN" "$BATS_TMPDIR/myfile.txt" doesnt_exist:/
|
|
assert_failure
|
|
assert_output --partial 'no containers matching'
|
|
|
|
run rm -rf "$BATS_TMPDIR/myfile.txt"
|
|
assert_success
|
|
|
|
_undeploy_app
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "copy to container" {
|
|
_deploy_app
|
|
|
|
run bash -c "echo foo >> $BATS_TMPDIR/myfile.txt"
|
|
assert_success
|
|
|
|
run $ABRA app cp "$TEST_APP_DOMAIN" "$BATS_TMPDIR/myfile.txt" app:/etc
|
|
assert_success
|
|
|
|
run rm -rf "$BATS_TMPDIR/myfile.txt"
|
|
assert_success
|
|
|
|
_undeploy_app
|
|
}
|
|
|
|
# bats test_tags=slow
|
|
@test "copy from container" {
|
|
_deploy_app
|
|
|
|
run bash -c "echo foo >> $BATS_TMPDIR/myfile.txt"
|
|
assert_success
|
|
|
|
run $ABRA app cp "$TEST_APP_DOMAIN" "$BATS_TMPDIR/myfile.txt" app:/etc
|
|
assert_success
|
|
|
|
run rm -rf "$BATS_TMPDIR/myfile.txt"
|
|
assert_success
|
|
|
|
run $ABRA app cp "$TEST_APP_DOMAIN" app:/etc/myfile.txt "$BATS_TMPDIR"
|
|
assert_success
|
|
assert_exists "$BATS_TMPDIR/myfile.txt"
|
|
assert bash -c "cat $BATS_TMPDIR/myfile.txt | grep -q foo"
|
|
|
|
run rm -rf "$BATS_TMPDIR/myfile.txt"
|
|
assert_success
|
|
|
|
_undeploy_app
|
|
}
|