From bef9697f297fee85e0e2f96ae3df4099527d2b07 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Wed, 6 Jun 2018 17:50:07 +0200 Subject: [PATCH] test: Add tests for the bintray commands Only one test is added for now as a proof of concept. --- test/bintray/README.md | 21 +++++++++++ test/bintray/test | 42 ++++++++++++++++++++++ test/bintray/upload/basic | 4 +++ test/bintray/upload/basic-dist | 4 +++ test/bintray/upload/basic-prerelease | 4 +++ test/bintray/upload/basic-prerelease-alpha | 4 +++ test/bintray/upload/basic-prerelease-beta | 4 +++ test/bintray/upload/basic-prerelease-rc | 4 +++ test/bintray/upload/basic-release | 4 +++ test/bintray/upload/comp | 4 +++ 10 files changed, 95 insertions(+) create mode 100644 test/bintray/README.md create mode 100755 test/bintray/test create mode 100644 test/bintray/upload/basic create mode 100644 test/bintray/upload/basic-dist create mode 100644 test/bintray/upload/basic-prerelease create mode 100644 test/bintray/upload/basic-prerelease-alpha create mode 100644 test/bintray/upload/basic-prerelease-beta create mode 100644 test/bintray/upload/basic-prerelease-rc create mode 100644 test/bintray/upload/basic-release create mode 100644 test/bintray/upload/comp diff --git a/test/bintray/README.md b/test/bintray/README.md new file mode 100644 index 0000000..d805d95 --- /dev/null +++ b/test/bintray/README.md @@ -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). diff --git a/test/bintray/test b/test/bintray/test new file mode 100755 index 0000000..cd9e0bb --- /dev/null +++ b/test/bintray/test @@ -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 diff --git a/test/bintray/upload/basic b/test/bintray/upload/basic new file mode 100644 index 0000000..81537d6 --- /dev/null +++ b/test/bintray/upload/basic @@ -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 diff --git a/test/bintray/upload/basic-dist b/test/bintray/upload/basic-dist new file mode 100644 index 0000000..435e7d0 --- /dev/null +++ b/test/bintray/upload/basic-dist @@ -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 diff --git a/test/bintray/upload/basic-prerelease b/test/bintray/upload/basic-prerelease new file mode 100644 index 0000000..cb30949 --- /dev/null +++ b/test/bintray/upload/basic-prerelease @@ -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 diff --git a/test/bintray/upload/basic-prerelease-alpha b/test/bintray/upload/basic-prerelease-alpha new file mode 100644 index 0000000..5596c76 --- /dev/null +++ b/test/bintray/upload/basic-prerelease-alpha @@ -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 diff --git a/test/bintray/upload/basic-prerelease-beta b/test/bintray/upload/basic-prerelease-beta new file mode 100644 index 0000000..3c9904d --- /dev/null +++ b/test/bintray/upload/basic-prerelease-beta @@ -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 diff --git a/test/bintray/upload/basic-prerelease-rc b/test/bintray/upload/basic-prerelease-rc new file mode 100644 index 0000000..b826230 --- /dev/null +++ b/test/bintray/upload/basic-prerelease-rc @@ -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 diff --git a/test/bintray/upload/basic-release b/test/bintray/upload/basic-release new file mode 100644 index 0000000..cf921f4 --- /dev/null +++ b/test/bintray/upload/basic-release @@ -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 diff --git a/test/bintray/upload/comp b/test/bintray/upload/comp new file mode 100644 index 0000000..96c84df --- /dev/null +++ b/test/bintray/upload/comp @@ -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