Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Gartland committed Jan 9, 2024
1 parent 20de8a2 commit ceba115
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
16 changes: 15 additions & 1 deletion test/bats/cli/tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,21 @@
load '../node_modules/bats-support/load'
load '../node_modules/bats-assert/load'

@test "${EXE} -h" {
@test "--help command succeeds" {
run ${EXE} -h
assert_success
}

@test "init creates expected file" {
python_version="$(python --version | awk '{print $2}')"
run ${EXE} init ../sample-content/fastapi-simple/
assert_success
run cat ../sample-content/fastapi-simple/.posit/publish/default.toml
assert_line "type = 'python-fastapi'"
assert_line "entrypoint = 'simple.py'"
assert_line "validate = true"
assert_line "title = 'fastapi-simple'"
assert_line "version = '$python_version'"
assert_line "package-file = 'requirements.txt'"
assert_line "package-manager = 'pip'"
}
32 changes: 27 additions & 5 deletions test/bats/contract/deploy.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
load '../node_modules/bats-support/load'
load '../node_modules/bats-assert/load'

# list-accounts should return the account from env
@test "list accounts" {
run ${EXE} list-accounts
assert_success
Expand All @@ -11,8 +12,33 @@ load '../node_modules/bats-assert/load'
assert_output --partial "Authentication: Connect API key"
}

# test-account should pass with env
@test "test accounts" {
run ${EXE} test-account env
assert_success
assert_output --partial "Name: Administrator Smith"
assert_output --partial "Username: admin"
assert_output --partial "Email: [email protected]"
}

# deploy content with the env account
@test "deploy content" {
run ${EXE} deploy ../sample-content/fastapi-simple/
run ${EXE} deploy ../sample-content/fastapi-simple/ -n ci_deploy
assert_success
assert_output --partial "Test Deployment... [OK]"
# now test the deployment via api
GUID="$(echo "${output}" | \
grep "Direct URL:" | \
grep -o -E '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')"
run curl --silent --show-error -L --max-redirs 0 --fail \
-X GET \
-H "Authorization: Key ${CONNECT_API_KEY}" "${CONNECT_SERVER}/__api__/v1/content/${GUID}"
assert_output --partial "\"app_mode\":\"python-fastapi\""
}

# redeploy content from previous test
@test "redeploy content" {
run ${EXE} redeploy ci_deploy ../sample-content/fastapi-simple/
assert_success
assert_output --partial "Test Deployment... [OK]"
# now test the deployment via api
Expand All @@ -25,7 +51,3 @@ load '../node_modules/bats-assert/load'
assert_output --partial "\"app_mode\":\"python-fastapi\""
}

# @test "pwd" {
# run ls ../
# assert_output --partial "blue"
# }

0 comments on commit ceba115

Please sign in to comment.