File: test_client.sh

package info (click to toggle)
python-spython 0.3.13-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 736 kB
  • sloc: python: 3,299; sh: 61; makefile: 28
file content (56 lines) | stat: -rwxr-xr-x 2,180 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash

# Include help functions
. helpers.sh

echo
echo "************** START: test_client.sh **********************"

# Create temporary testing directory
echo "Creating temporary directory to work in."
tmpdir=$(mktemp -d)
output=$(mktemp ${tmpdir:-/tmp}/spython_test.XXXXXX)
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

echo "Testing help commands..."

# Test help for all commands
for command in recipe shell;
    do
    runTest 0 $output spython $command --help
done

echo "#### Testing recipe auto generation"
runTest 1 $output spython recipe $here/testdata/Dockerfile | grep "FROM"
runTest 0 $output spython recipe $here/testdata/Dockerfile | grep "%post"
runTest 1 $output spython recipe $here/testdata/Singularity | grep "%post"
runTest 0 $output spython recipe $here/testdata/Singularity | grep "FROM"

echo "#### Testing recipe targeted generation"
runTest 0 $output spython recipe --writer docker $here/testdata/Dockerfile | grep "FROM"
runTest 1 $output spython recipe --writer docker $here/testdata/Dockerfile | grep "%post"
runTest 0 $output spython recipe --writer singularity $here/testdata/Singularity | grep "%post"
runTest 1 $output spython recipe --writer singularity $here/testdata/Singularity | grep "FROM"

echo "#### Testing recipe file generation"
outfile=$(mktemp ${tmpdir:-/tmp}/spython_recipe.XXXXXX)
runTest 0 $output spython recipe $here/testdata/Dockerfile $outfile
runTest 0 $output test -f "$outfile"
runTest 0 $output cat $outfile | grep "%post"
rm $outfile

echo "#### Testing recipe json export"
runTest 0 $output spython recipe --json $here/testdata/Dockerfile | grep "ports"
runTest 0 $output spython recipe $here/testdata/Dockerfile $outfile
runTest 0 $output test -f "$outfile"
runTest 0 $output cat $outfile | grep "%post"

# Force is false, should fail
echo "#### Testing recipe json export, writing to file"
runTest 0 $output spython recipe --json $here/testdata/Dockerfile $outfile
runTest 0 $output spython recipe --force --json $here/testdata/Dockerfile $outfile
runTest 0 $output test -f "$outfile"
runTest 0 $output cat $outfile | grep "ports"

echo "Finish testing basic client"
rm -rf ${tmpdir}