all repos — dot @ master

Shell, editor and terminal configuration, and the tools that go with them

secrets/test/ready.sh (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
#!/bin/bash
# Tests for ready command

this_dir="$(cd "$(dirname "$0")" && pwd)"
source "${this_dir}/common.sh"

test_ready_with_key() {
    assert_success szecret ready
    pass "ready succeeds with private key"
}

test_ready_without_key() {
    local saved_key="${SZECRET_PRIVATE_KEY}"
    export SZECRET_PRIVATE_KEY="${TEST_DIR}/nonexistent-key"

    assert_failure szecret ready

    export SZECRET_PRIVATE_KEY="${saved_key}"
    pass "ready fails without private key"
}

run_tests() {
    test_ready_with_key
    test_ready_without_key
}

[[ "${BASH_SOURCE[0]}" == "${0}" ]] && run_tests