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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#!/usr/bin/env bash
test_description='cli'
. lib/test-lib.sh
################################################################
test_expect_code 5 'dump non-existant db' \
'impass dump'
test_expect_success 'add first entry' \
'impass add foo@bar'
test_expect_success 'add second entry' \
"impass add 'baz asdf Dokw okb 32438uoijdf'"
test_expect_code 2 'add existing context' \
'impass add foo@bar'
test_begin_subtest "dump all entries"
impass dump 2>&1 | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
"baz asdf Dokw okb 32438uoijdf": {
FOO
},
"foo@bar": {
FOO
}
}
EOF
test_expect_equal_file OUTPUT EXPECTED
test_begin_subtest "dump search 0"
impass dump foo 2>&1 | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
"foo@bar": {
FOO
}
}
EOF
test_expect_equal_file OUTPUT EXPECTED
test_begin_subtest "dump search 1"
impass dump asdf 2>&1 | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
"baz asdf Dokw okb 32438uoijdf": {
FOO
}
}
EOF
test_expect_equal_file OUTPUT EXPECTED
test_begin_subtest "dump search 2"
impass dump ba 2>&1 | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
"baz asdf Dokw okb 32438uoijdf": {
FOO
},
"foo@bar": {
FOO
}
}
EOF
test_expect_equal_file OUTPUT EXPECTED
test_expect_code 2 'add existing context' 'impass add foo@bar'
test_expect_code 2 'replace non-existing context' \
'impass replace aaaa'
# FIXME: add replacement test
test_expect_code 2 'update non-existing context' \
'impass update aaaa'
test_begin_subtest "update entry"
impass update foo@bar foo@example
impass dump foo 2>&1 | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
"foo@example": {
FOO
}
}
EOF
test_expect_equal_file OUTPUT EXPECTED
test_expect_code 2 'remove non-existant entry' 'impass remove aaaa'
test_begin_subtest "remove entry"
echo yes | impass remove foo@example
impass dump 2>&1 | sed 's/"date": ".*"/FOO/g' >OUTPUT
cat <<EOF >EXPECTED
{
"baz asdf Dokw okb 32438uoijdf": {
FOO
}
}
EOF
test_expect_equal_file OUTPUT EXPECTED
################################################################
test_done
|