Added a basic smoke test
This commit is contained in:
parent
19f06b165c
commit
6a9616f648
1
tests/README
Normal file
1
tests/README
Normal file
@ -0,0 +1 @@
|
|||||||
|
This is a repo for tests for python-jsonpointer.
|
63
tests/Sanity/smoke/Makefile
Normal file
63
tests/Sanity/smoke/Makefile
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
#
|
||||||
|
# Makefile of /tools/python-jsonpointer/Sanity/smoke
|
||||||
|
# Description: Testing of basic functionality.
|
||||||
|
# Author: Peter Hostacny <phostacn@redhat.com>, Jan Kuřík <jkurik@redhat.com>
|
||||||
|
#
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 2 of
|
||||||
|
# the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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, see http://www.gnu.org/licenses/.
|
||||||
|
#
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
export TEST=/tools/python-jsonpointer/Sanity/smoke
|
||||||
|
export TESTVERSION=1.0
|
||||||
|
|
||||||
|
BUILT_FILES=
|
||||||
|
|
||||||
|
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||||
|
|
||||||
|
.PHONY: all install download clean
|
||||||
|
|
||||||
|
run: $(FILES) build
|
||||||
|
./runtest.sh
|
||||||
|
|
||||||
|
build: $(BUILT_FILES)
|
||||||
|
test -x runtest.sh || chmod a+x runtest.sh
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *~ $(BUILT_FILES)
|
||||||
|
|
||||||
|
|
||||||
|
include /usr/share/rhts/lib/rhts-make.include
|
||||||
|
|
||||||
|
$(METADATA): Makefile
|
||||||
|
@echo "Owner: Jan Kuřík <jkurik@redhat.com>" > $(METADATA)
|
||||||
|
@echo "Name: $(TEST)" >> $(METADATA)
|
||||||
|
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||||
|
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||||
|
@echo "Description: Testing of basic functionality." >> $(METADATA)
|
||||||
|
@echo "Type: Sanity" >> $(METADATA)
|
||||||
|
@echo "TestTime: 5m" >> $(METADATA)
|
||||||
|
@echo "RunFor: python-jsonpointer" >> $(METADATA)
|
||||||
|
@echo "Requires: python-jsonpointer python2-jsonpointer python3-jsonpointer" >> $(METADATA)
|
||||||
|
@echo "Priority: Normal" >> $(METADATA)
|
||||||
|
@echo "License: GPLv2+" >> $(METADATA)
|
||||||
|
@echo "Confidential: no" >> $(METADATA)
|
||||||
|
@echo "Destructive: no" >> $(METADATA)
|
||||||
|
@echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA)
|
||||||
|
|
||||||
|
rhts-lint $(METADATA)
|
3
tests/Sanity/smoke/PURPOSE
Normal file
3
tests/Sanity/smoke/PURPOSE
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
PURPOSE of /tools/python-jsonpointer/Sanity/smoke
|
||||||
|
Description: Test of basic functionality.
|
||||||
|
Author: Jan Kuřík <jkurik@redhat.com>
|
14
tests/Sanity/smoke/main.fmf
Normal file
14
tests/Sanity/smoke/main.fmf
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
summary: Testing of basic functionality.
|
||||||
|
description: ''
|
||||||
|
contact: Jan Kuřík <jkurik@redhat.com>
|
||||||
|
component:
|
||||||
|
- python-jsonpointer
|
||||||
|
test: ./runtest.sh
|
||||||
|
framework: beakerlib
|
||||||
|
recommend:
|
||||||
|
- python-jsonpointer
|
||||||
|
- python2-jsonpointer
|
||||||
|
- python3-jsonpointer
|
||||||
|
duration: 5m
|
||||||
|
extra-summary: /tools/python-jsonpointer/Sanity/smoke
|
||||||
|
extra-task: /tools/python-jsonpointer/Sanity/smoke
|
68
tests/Sanity/smoke/runtest.sh
Executable file
68
tests/Sanity/smoke/runtest.sh
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
#
|
||||||
|
# runtest.sh of /tools/python-jsonpointer/Sanity/smoke
|
||||||
|
# Description: Testing of basic functionality.
|
||||||
|
# Author: Peter Hostacny <phostacn@redhat.com>, Jan Kuřík <jkurik@redhat.com>
|
||||||
|
#
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015-2021 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 2 of
|
||||||
|
# the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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, see http://www.gnu.org/licenses/.
|
||||||
|
#
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
# Include Beaker environment
|
||||||
|
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||||
|
|
||||||
|
rlJournalStart
|
||||||
|
rlPhaseStartSetup
|
||||||
|
if rpm -q --quiet python-jsonpointer; then
|
||||||
|
PACKAGE="python-jsonpointer"
|
||||||
|
elif rpm -q --quiet python3-jsonpointer; then
|
||||||
|
PACKAGE="python3-jsonpointer"
|
||||||
|
else
|
||||||
|
rlDie "No python's jsonpointer package is installed"
|
||||||
|
fi
|
||||||
|
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
||||||
|
rlRun "pushd $TmpDir"
|
||||||
|
|
||||||
|
rlRun "echo '{ \"a\": [1, 2, 3] }' > a.json" 0 "Creating test-file."
|
||||||
|
rlRun "echo '{ \"a\": {\"b\": [1, 3, 4]}, \"b\": 1 }' > b.json" 0 "Creating test-file."
|
||||||
|
rlRun "echo '\"/a\"' > ptr.json" 0 "Creating test-file."
|
||||||
|
|
||||||
|
# Setting of pipefail shell option
|
||||||
|
set -o pipefail
|
||||||
|
rlPhaseEnd
|
||||||
|
|
||||||
|
rlPhaseStartTest
|
||||||
|
if rlTestVersion $(rpm -q --qf '%{version}' ${PACKAGE}) '<' 2; then
|
||||||
|
__ptr="ptr.json"
|
||||||
|
else
|
||||||
|
__ptr=$(tr -d '"' < ptr.json)
|
||||||
|
fi
|
||||||
|
rlRun -s "jsonpointer '${__ptr}' a.json b.json" 0 \
|
||||||
|
"Testing of jsonpointer commandline utility - simple run."
|
||||||
|
rlAssertGrep "[1, 2, 3]" "${rlRun_LOG}"
|
||||||
|
rlAssertGrep "{\"b\": \[1, 3, 4\]}" "${rlRun_LOG}"
|
||||||
|
rlPhaseEnd
|
||||||
|
|
||||||
|
rlPhaseStartCleanup
|
||||||
|
rlRun "popd"
|
||||||
|
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||||
|
rlPhaseEnd
|
||||||
|
rlJournalPrintText
|
||||||
|
rlJournalEnd
|
Loading…
Reference in New Issue
Block a user