node js tests

This commit is contained in:
Tomas Juhasz 2025-01-03 11:33:05 +01:00
commit f1ee23f5fa
26 changed files with 935 additions and 2 deletions

View file

@ -0,0 +1,7 @@
summary: Runs internal expressjs tests.
description: |
Test to verify Expresss compatibility with the Node.js.
duration: 5m
require:
- nodejs
- git

View file

@ -0,0 +1,63 @@
#!/bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Description: Basic sanity test for express module.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2020 Red Hat, Inc.
#
# 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
# Packages to be tested
PACKAGES=${PACKAGES:-nodejs nodejs-npm}
# Other required packages
REQUIRES=${REQUIRES:-git}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm --all
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest "Testsuite"
rlRun "git clone https://github.com/expressjs/express.git" 0 "Clone the upstream repo with the Express framework"
rlRun "pushd express" 0 "Change directory to the express repo directory"
rlRun "latest_express=$(npm show express version)" 0 "Figuring out what the latest express version is"
rlLog "Latest Express version: ${latest_express}"
rlRun "git stash" 0 "Stashing eventual changes so they don't prevent checkout"
rlRun "git checkout '${latest_express}'" 0 "Checkout git's tag ${latest_express}"
rlRun "npm install mocha"
rlRun -s "npm test" 0 "Running the test-suite"
rlAssertGrep "[0-9]* passing" "$rlRun_LOG" -E
rlAssertNotGrep "[0-9]* failing" "$rlRun_LOG" -E
rlAssertNotGrep "Test failed" "$rlRun_LOG"
rlRun "popd" 0 "Get back to the original directory"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd