Skip to content

Commit

Permalink
test: Add tests for the bintray commands
Browse files Browse the repository at this point in the history
Only one test is added for now as a proof of concept.
  • Loading branch information
leandro-lucarella-sociomantic committed Jun 8, 2018
1 parent 2969c58 commit bef9697
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/bintray/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
bintray commands tests
======================

Tests for the `upload` subcommand should live in the `upload` directory, and
each file in that directory is a separate test and should have the following
format:
```
CMD
RET
OUT
...
```

Where:

- `CMD` is the full command to run (one line).
- `RET` is the expected return code for the command (one line).
- `OUT` is the expected output of the command. If `RET` is `0`, then this is
expected to be the *stdout* output. Otherwise is expected to be the *stderr*
output (multiple lines, all until the end of the file is considered the
output).
42 changes: 42 additions & 0 deletions test/bintray/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
set -u

stdout=$(mktemp beaver.test.stdout.XXXXXXXX)
stderr=$(mktemp beaver.test.stderr.XXXXXXXX)
expout=$(mktemp beaver.test.expout.XXXXXXXX)

trap 'r=$?; rm -f "$stdout" "$stderr" "$expout"; exit $r' EXIT

# Default DIST
export DIST=xenial

ret=0

for f in upload/*
do
echo "running $(basename "$f"): $(sed -n 1p < "$f")"
eval $(sed -n 1p < "$f") > "$stdout" 2> "$stderr"
r=$?

expected_r=$(sed -n 2p < "$f")
if test "$r" -ne "$expected_r"
then
echo "Error: Return is $r, expected $expected_r" >&2
ret=1
fi

if test $r -eq 0
then
out="$stdout"
else
out="$stderr"
fi

sed '1,2d' < "$f" > "$expout"
diff -u "$expout" "$out" || ret=1

test "$ret" -ne 0 &&
exit $ret
done

exit $ret
4 changes: 4 additions & 0 deletions test/bintray/upload/basic
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BINTRAY_USER=user TRAVIS_TAG=not-a-tag TRAVIS_REPO_SLUG=sociomantic/test beaver bintray upload -N -k test -n pkg.deb
0
jfrog bt version-create --desc= --vcs-tag=not-a-tag --released= sociomantic/test/test/not-a-tag
jfrog bt upload --publish=true --override=false --deb=xenial/prerelease/pkg.deb pkg.deb sociomantic/test/test/not-a-tag
4 changes: 4 additions & 0 deletions test/bintray/upload/basic-dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BINTRAY_USER=user TRAVIS_TAG=not-a-tag TRAVIS_REPO_SLUG=sociomantic/test beaver bintray upload -D bionic -N -k test -n pkg.deb
0
jfrog bt version-create --desc= --vcs-tag=not-a-tag --released= sociomantic/test/test/not-a-tag
jfrog bt upload --publish=true --override=false --deb=bionic/prerelease/pkg.deb pkg.deb sociomantic/test/test/not-a-tag
4 changes: 4 additions & 0 deletions test/bintray/upload/basic-prerelease
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BINTRAY_USER=user TRAVIS_TAG=v0.0.1-pre.1 TRAVIS_REPO_SLUG=sociomantic/test beaver bintray upload -N -k test -n pkg.deb
0
jfrog bt version-create --desc= --vcs-tag=v0.0.1-pre.1 --released= sociomantic/test/test/v0.0.1-pre.1
jfrog bt upload --publish=true --override=false --deb=xenial/prerelease/pkg.deb pkg.deb sociomantic/test/test/v0.0.1-pre.1
4 changes: 4 additions & 0 deletions test/bintray/upload/basic-prerelease-alpha
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BINTRAY_USER=user TRAVIS_TAG=v0.0.1-alpha TRAVIS_REPO_SLUG=sociomantic/test beaver bintray upload -N -k test -n pkg.deb
0
jfrog bt version-create --desc= --vcs-tag=v0.0.1-alpha --released= sociomantic/test/test/v0.0.1-alpha
jfrog bt upload --publish=true --override=false --deb=xenial/prerelease/pkg.deb pkg.deb sociomantic/test/test/v0.0.1-alpha
4 changes: 4 additions & 0 deletions test/bintray/upload/basic-prerelease-beta
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BINTRAY_USER=user TRAVIS_TAG=v0.0.1-beta.10 TRAVIS_REPO_SLUG=sociomantic/test beaver bintray upload -N -k test -n pkg.deb
0
jfrog bt version-create --desc= --vcs-tag=v0.0.1-beta.10 --released= sociomantic/test/test/v0.0.1-beta.10
jfrog bt upload --publish=true --override=false --deb=xenial/prerelease/pkg.deb pkg.deb sociomantic/test/test/v0.0.1-beta.10
4 changes: 4 additions & 0 deletions test/bintray/upload/basic-prerelease-rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BINTRAY_USER=user TRAVIS_TAG=v0.0.1-rc.1 TRAVIS_REPO_SLUG=sociomantic/test beaver bintray upload -N -k test -n pkg.deb
0
jfrog bt version-create --desc= --vcs-tag=v0.0.1-rc.1 --released= sociomantic/test/test/v0.0.1-rc.1
jfrog bt upload --publish=true --override=false --deb=xenial/prerelease/pkg.deb pkg.deb sociomantic/test/test/v0.0.1-rc.1
4 changes: 4 additions & 0 deletions test/bintray/upload/basic-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BINTRAY_USER=user TRAVIS_TAG=v0.0.1 TRAVIS_REPO_SLUG=sociomantic/test beaver bintray upload -N -k test -n pkg.deb
0
jfrog bt version-create --desc= --vcs-tag=v0.0.1 --released= sociomantic/test/test/v0.0.1
jfrog bt upload --publish=true --override=false --deb=xenial/release/pkg.deb pkg.deb sociomantic/test/test/v0.0.1
4 changes: 4 additions & 0 deletions test/bintray/upload/comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BINTRAY_USER=user TRAVIS_TAG=not-a-tag TRAVIS_REPO_SLUG=sociomantic/test beaver bintray upload -N -C comp -k api-key -n lala.deb
0
jfrog bt version-create --desc= --vcs-tag=not-a-tag --released= sociomantic/test/test/not-a-tag
jfrog bt upload --publish=true --override=false --deb=xenial/comp/lala.deb lala.deb sociomantic/test/test/not-a-tag

0 comments on commit bef9697

Please sign in to comment.