From 25b478a9755a2da88a23a9947c543050ace220f9 Mon Sep 17 00:00:00 2001
From: Felipe Shi Iu Wu <felipeshiwu@gmail.com>
Date: Wed, 19 Oct 2016 11:34:25 -0200
Subject: [PATCH] Issue #27: Integrate create_user and return test

Signed-off-by: Felipe Shi Iu Wu <felipeshiwu@gmail.com>
---
 .gitlab-ci.yml       | 15 ++++++++++++---
 test/returnTest.bats |  3 ++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ce7cd633..46ca80e4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -41,11 +41,13 @@ testDebian:
         - regular
         - debian
     script:
-        - apt-get update && apt-get install -y git jq
+        - apt-get update && apt-get install -y git jq faketime expect
         - git clone https://github.com/sstephenson/bats.git
         - cd bats 
         - ./install.sh /usr 
         - cd ../test
+        - ./create_users.sh
+        - last -F
         - ./returnTest.bats
     dependencies:
         - compile
@@ -56,8 +58,10 @@ testUbuntu:
         - ubuntu
         - regular
     script:
-        - apt-get update && apt-get install -y bats jq
+        - apt-get update && apt-get install -y bats jq faketime expect
         - cd test
+        - ./create_users.sh
+        - last -F
         - ./returnTest.bats
     dependencies:
         - compile
@@ -68,8 +72,13 @@ testOpensuse:
         - opensuse
     script:
         - zypper -n update
-        - zypper -n install bats && zypper -n install jq
+        - zypper -n install bats jq libfaketime expect
+        - touch /var/log/wtmp
+        - chown root.tty /var/log/wtmp
+        - chmod 664 /var/log/wtmp
         - cd test
+        - ./create_users.sh
+        - last -F
         - ./returnTest.bats
     dependencies:
         - compile
diff --git a/test/returnTest.bats b/test/returnTest.bats
index 1dde190f..f1b41734 100755
--- a/test/returnTest.bats
+++ b/test/returnTest.bats
@@ -1,8 +1,9 @@
 #!/usr/bin/env bats
 
 function amount_users() {
+    expected_number_of_users=3
     obj=$(cat export.json | jq -r '.data.amount_users')
-    [[ "$obj" -eq "$obj" ]] && [[ "$obj" != "null" ]]
+    [[ "$obj" -eq "$expected_number_of_users" ]] && [[ "$obj" != "null" ]]
 }
 
 function mac_address() {
-- 
GitLab