File tree Expand file tree Collapse file tree 3 files changed +46
-3
lines changed
Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Original file line number Diff line number Diff line change 11clean :
22
3+ check :
4+ ./test-apt-dater-host
5+
36install :
47 install -D -m0755 apt-dater-host \
58 $(DESTDIR ) /usr/bin/apt-dater-host
Original file line number Diff line number Diff line change 1010# Henrik Riomar <[email protected] >1111#
1212# Copyright Holder:
13- # 2016 (C) Henrik Riomar
13+ # 2016, 2017 (C) Henrik Riomar
1414#
1515# License:
1616# This program is free software; you can redistribute it and/or modify
@@ -52,7 +52,7 @@ get_prl()
5252# check if a pkg is held back
5353is_held ()
5454{
55- grep -E -q ^$1 \= /etc/apk/world
55+ grep -E -q -e ^$1 \= -e ^ $1 \< /etc/apk/world
5656}
5757
5858# check if $1 > $2
@@ -71,7 +71,7 @@ get_pkg_stat()
7171 $APK_CMD info | while read -r pkg
7272 do
7373 line=$( grep -E " ^${pkg} -[0-9]" $tmp )
74- new_ver=$( echo $line | awk ' {print $NF}' )
74+ new_ver=$( echo $line | sed ' s/ @.\+$// ' | awk ' {print $NF}' )
7575 cur_ver=$( echo $line | awk ' {print $1}' | sed " s/$pkg -//" )
7676 if [ x" $new_ver " = x" $cur_ver " ]; then
7777 echo " STATUS: $pkg |$cur_ver |i"
@@ -212,6 +212,10 @@ case "$1" in
212212 get_kern
213213 ;;
214214
215+ source-only)
216+ # do nothing (used for unit testing)
217+ ;;
218+
215219 * )
216220 echo Invalid command \' $1 \'\!
217221 exit $err
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env bats
2+
3+ source ./apt-dater-host source-only
4+
5+ check_tag()
6+ {
7+ TAG=$1
8+ STR=$2
9+ [ $(echo $STR | grep -E -v -c "^$TAG:") -eq 0 ]
10+ }
11+
12+ @test "say_hi()" {
13+ result="$(say_hi)"
14+ check_tag ADPROTO $result
15+ [ "$result" = "ADPROTO: 0.6" ]
16+ }
17+
18+ @test "get_lsbrel()" {
19+ result="$(get_lsbrel)"
20+ check_tag LSBREL $result
21+ }
22+
23+ @test "get_pkg_stat()" {
24+ result="$(get_pkg_stat)"
25+ check_tag STATUS $result
26+ }
27+
28+ @test "get_virt()" {
29+ result="$(get_virt)"
30+ check_tag VIRT $result
31+ }
32+
33+ @test "get_kern()" {
34+ result="$(get_kern)"
35+ check_tag KERNELINFO $result
36+ }
You can’t perform that action at this time.
0 commit comments