#!/bin/bash # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # Author: Tomas Juhasz # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # Copyright (c) 2013 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing # to use, modify, copy, or redistribute it subject to the terms # and conditions of the GNU General Public License version 2. # # This program is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this program; if not, write to the Free # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ . /usr/share/beakerlib/beakerlib.sh || exit 1 SQLITE_TEST_SCRIPT='test-sqlite.js' # Name of the SQLite test script #Expected values EXPECTED_SUBSTRING_B="{ key: 1, value: 'hello' }" EXPECTED_SUBSTRING_S="Test Passed" #Script Files SQLITE_TEST_SCRIPT='sqlite.js' SQLITE_TEST_SCRIPT_SESSION='sqlite-sessions.js' NODEJS=${NODEJS:-node} NPMJS=${NPMJS:-npm} rlJournalStart rlPhaseStartSetup #Push everything into temp directory rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" rlRun "cp $SQLITE_TEST_SCRIPT \$tmp/$SQLITE_TEST_SCRIPT" rlRun "cp $SQLITE_TEST_SCRIPT_SESSION \$tmp/$SQLITE_TEST_SCRIPT_SESSION" rlRun "pushd \$tmp" rlPhaseEnd rlPhaseStartTest rlLogInfo "Running SQLite test script" rlRun "$NPMJS install sqlite" rlRun "$NODEJS --experimental-sqlite $SQLITE_TEST_SCRIPT > output.txt" 0 "Execute Node.js SQLite test script" OUTPUT=$(cat output.txt) #Run just a standart script using sqlite rlAssertGrep "$EXPECTED_SUBSTRING_B" output.txt rlRun "$NODEJS --experimental-sqlite $SQLITE_TEST_SCRIPT_SESSION > output_session.txt" 0 "Execute Node.js SQLite test script" OUTPUT=$(cat output_session.txt) #Run script using sqlite which utilizes the session feature rlAssertGrep "$EXPECTED_SUBSTRING_S" output_session.txt rlPhaseEnd rlPhaseStartCleanup rlLogInfo "Cleaning up test environment" rlRun "$NPMJS remove sqlite" rlRun "rm -r *" rlRun "popd" rlRun "rm -r \$tmp" 0 "Remove tmp directory" rlPhaseEnd rlJournalEnd