Create admin session cookie file only in JSON workflow
This PR implements the issue #12:
The admin session cookie file is, I believe, needed only to allow backup and restoration of the Ghost JSON export. So when the backup/restore workflow doesn't involve the Ghost JSON export, the function that create the admin session cookie file should not be invoked.
How is it done?
I've removed invocation to createGhostAdminCookie() from the bottom of common.sh, so it stops being called automatically, even when the -J option is passed to the backup command.
Then, I've added invocation of that function at the top of the blocks where it is needed, namely in the backupGhostJsonFile() and restoreGhostJsonFile() functions.
How to test?
I have added automated unit tests in the tests/ directory. After installing bats-core, they can be run as shown below:
$ bats tests
json_export_workflow.bats
✓ Don't call function to create cookie when -J is passed
✓ Function to create cookie is called when JSON backup is enabled
✓ Function to create cookie is called when restoring JSON file
3 tests, 0 failures