Add project2sr() and url2sr() to tsp/common.sh
Add tests of url2sr function to test/tct_common.bats
Change-Id: Ib4ecc900f0791578ab13110a28e63d634234f86d
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
--- /dev/null
+#!/usr/bin/env bats
+
+. ./tsp/common.sh
+
+@test "url2sr: no args" {
+ RES1="$(url2sr 2>&1)" || RES2="$?"
+ [ -n "$RES1" ]
+ [ "$RES2" -ne 0 ]
+}
+
+@test "url2sr: pre_url" {
+ RES1="$(url2sr http://download.tizen.org/prerelease/tizen/common/tizen-common_20160613.3/tizen-common_20160613.3.20160614.075200/ 2>&1)"
+ [ "$RES1" = "tizen-common_20160613.3.20160614.075200" ]
+}
+
+@test "url2sr: snap_url" {
+ RES1="$(url2sr http://download.tizen.org/snapshots/tizen/common/tizen-common_20160909.2/ 2>&1)"
+ [ "$RES1" = "tizen-common_20160909.2" ]
+}
shift
TMPDIR="$TMPDIR" TS_SLOTS=1 tsp $@
}
+
+url2sr() {
+ URL="$1"
+ test -n "$URL" || die "Missing argument: url"
+ RET="${URL%/}"
+ RET="${RET##*/}"
+ echo "$RET"
+}
+
+project2sr() {
+ PROJECT_FILE="$1"
+ test -n "$PROJECT_FILE" || die "Missing argument: project_file"
+ head -n 1 "${PROJECT_FILE}" | tr -d '\n'
+}