acoeur/bin/_commands/prop_test.bats
2022-10-26 23:38:40 +02:00

132 lines
3.5 KiB
Bash
Executable File

#!/usr/bin/env bats
setup() {
mkdir -p content/users/test
}
@test "Create property" {
echo "title: Simple create test" > content/users/test/create_prop_test.prop
! grep -o "^title: Simple create test" content/users/test/create_prop_test.md
bin/ac_route.sh "$(pwd)/content/users/test" create_prop_test.prop
[ -e content/users/test/create_prop_test.md ]
grep -o "^title: Simple create test" content/users/test/create_prop_test.md
}
@test "Update property" {
echo "---
title: Simple update test
---
" > content/users/test/update_prop_test.md
echo "title: Simple edit" > content/users/test/update_prop_test.prop
! grep -o "^title: Simple edit" content/users/test/update_prop_test.md
bin/ac_route.sh "$(pwd)/content/users/test" update_prop_test.prop
[ -e content/users/test/update_prop_test.md ]
grep -o "^title: Simple edit" content/users/test/update_prop_test.md
}
@test "Delete property" {
echo "---
title: Simple delete test
---
" > content/users/test/delete_prop_test.md
echo "title: " > content/users/test/delete_prop_test.prop
grep -o "^title:" content/users/test/delete_prop_test.md
bin/ac_route.sh "$(pwd)/content/users/test" delete_prop_test.prop
[ -e content/users/test/delete_prop_test.md ]
! grep -o "^title:" content/users/test/delete_prop_test.md
}
@test "Insert new ac_choice" {
echo "---
title: Simple ac_choice new insert test
---
" > content/users/test/choice_new_insert_test.md
echo "ac_choices[0]: new choice" > content/users/test/choice_new_insert_test.prop
bin/ac_route.sh "$(pwd)/content/users/test" choice_new_insert_test.prop
[ -e content/users/test/choice_new_insert_test.md ]
cat content/users/test/choice_new_insert_test.md
grep -o "^- new choice" content/users/test/choice_new_insert_test.md
}
@test "Insert ac_choice" {
echo "---
title: Simple ac_choice insert test
ac_choices:
- choice number 1
- choice number 2
- choice number 3
world: hello
hello: world
---
" > content/users/test/choice_insert_test.md
echo "ac_choices[3]: new choice" > content/users/test/choice_insert_test.prop
bin/ac_route.sh "$(pwd)/content/users/test" choice_insert_test.prop
[ -e content/users/test/choice_insert_test.md ]
cat content/users/test/choice_insert_test.md
grep -o "^- new choice" content/users/test/choice_insert_test.md
grep -o "^- choice number 3" content/users/test/choice_insert_test.md
grep -o "^hello: world" content/users/test/choice_insert_test.md
}
@test "Update ac_choice" {
echo "---
title: Simple ac_choice update test
ac_choices:
- choice number 1
- choice number 2
- choice number 3
---
" > content/users/test/choice_update_test.md
echo "ac_choices[2]: updated choice" > content/users/test/choice_update_test.prop
bin/ac_route.sh "$(pwd)/content/users/test" choice_update_test.prop
[ -e content/users/test/choice_update_test.md ]
cat content/users/test/choice_update_test.md
grep -o "^- updated choice" content/users/test/choice_update_test.md
grep -v "^- choice number 3" content/users/test/choice_update_test.md
}
@test "Delete ac_choice" {
echo "---
title: Simple ac_choice delete test
ac_choices:
- choice number 1
- choice number 2
- choice number 3
---
" > content/users/test/choice_delete_test.md
echo "ac_choices[2]: " > content/users/test/choice_delete_test.prop
grep -o "^- choice number 3" content/users/test/choice_delete_test.md
bin/ac_route.sh "$(pwd)/content/users/test" choice_delete_test.prop
[ -e content/users/test/choice_delete_test.md ]
! grep -o "^- choice number 3" content/users/test/choice_delete_test.md
}
teardown() {
rm -rf content/users/test
}