diff options
Diffstat (limited to 'testing/apt-dater-host/0001-apk-add-some-unit-tests-called-via-make-check.patch')
-rw-r--r-- | testing/apt-dater-host/0001-apk-add-some-unit-tests-called-via-make-check.patch | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/testing/apt-dater-host/0001-apk-add-some-unit-tests-called-via-make-check.patch b/testing/apt-dater-host/0001-apk-add-some-unit-tests-called-via-make-check.patch new file mode 100644 index 0000000000..6d4eec2db2 --- /dev/null +++ b/testing/apt-dater-host/0001-apk-add-some-unit-tests-called-via-make-check.patch @@ -0,0 +1,95 @@ +From a52c54d9b918f7683315e5206fd5e8d62f36b589 Mon Sep 17 00:00:00 2001 +From: Henrik Riomar <henrik.riomar@gmail.com> +Date: Wed, 15 Mar 2017 06:38:05 +0100 +Subject: [PATCH] apk: add some unit tests, called via "make check" + +Upstream-Issue: https://github.com/DE-IBH/apt-dater-host/pull/19 +--- + apk/Makefile | 3 +++ + apk/apt-dater-host | 6 +++++- + apk/test-apt-dater-host | 36 ++++++++++++++++++++++++++++++++++++ + 3 files changed, 44 insertions(+), 1 deletion(-) + create mode 100755 apk/test-apt-dater-host + +diff --git a/apk/Makefile b/apk/Makefile +index 227f366..dfe7d9e 100644 +--- a/apk/Makefile ++++ b/apk/Makefile +@@ -1,5 +1,8 @@ + clean: + ++check: ++ ./test-apt-dater-host ++ + install: + install -D -m0755 apt-dater-host \ + $(DESTDIR)/usr/bin/apt-dater-host +diff --git a/apk/apt-dater-host b/apk/apt-dater-host +index 2164dea..e0c9b65 100755 +--- a/apk/apt-dater-host ++++ b/apk/apt-dater-host +@@ -10,7 +10,7 @@ + # Henrik Riomar <henrik.riomar@gmail.com> + # + # Copyright Holder: +-# 2016 (C) Henrik Riomar ++# 2016,2017 (C) Henrik Riomar + # + # License: + # This program is free software; you can redistribute it and/or modify +@@ -212,6 +212,10 @@ case "$1" in + get_kern + ;; + ++ source-only) ++ # do nothing (used for unit testing) ++ ;; ++ + *) + echo Invalid command \'$1\'\! + exit $err +diff --git a/apk/test-apt-dater-host b/apk/test-apt-dater-host +new file mode 100755 +index 0000000..eef6d2b +--- /dev/null ++++ b/apk/test-apt-dater-host +@@ -0,0 +1,36 @@ ++#!/usr/bin/env bats ++ ++source ./apt-dater-host source-only ++ ++check_tag() ++{ ++ TAG=$1 ++ STR=$2 ++ [ $(echo $STR | grep -E -v -c "^$TAG:") -eq 0 ] ++} ++ ++@test "say_hi()" { ++ result="$(say_hi)" ++ check_tag ADPROTO $result ++ [ "$result" = "ADPROTO: 0.6" ] ++} ++ ++@test "get_lsbrel()" { ++ result="$(get_lsbrel)" ++ check_tag LSBREL $result ++} ++ ++@test "get_pkg_stat()" { ++ result="$(get_pkg_stat)" ++ check_tag STATUS $result ++} ++ ++@test "get_virt()" { ++ result="$(get_virt)" ++ check_tag VIRT $result ++} ++ ++@test "get_kern()" { ++ result="$(get_kern)" ++ check_tag KERNELINFO $result ++} +-- +2.11.1 + |