Skip to content
Snippets Groups Projects
Commit 50bcf361 authored by Felipe Shi Iu Wu's avatar Felipe Shi Iu Wu
Browse files

Issue #13: implement initial end-to-end tests

parent 31f73bd2
No related branches found
No related tags found
2 merge requests!51Merge development to master,!12Issue #13: implement initial end-to-end tests
Pipeline #
......@@ -7,27 +7,32 @@ compile:
artifacts:
paths:
- bin/
- build/
tags:
- build
- regular
- debian
script:
- echo "Estágio 'build'"
- apt-get update && apt-get install -y build-essential && apt-get install -y cmake
- apt-get install -y git
- apt-get update && apt-get install -y build-essential cmake git
- git submodule init
- git submodule update --init --recursive
- mkdir build
- cd build
- cmake ..
- cmake -DPRINT_JSON=ON ..
- make
testDebian:
stage: test
tags:
- build
- regular
- debian
script:
- echo "It works debian:8"
- apt-get update && apt-get install -y git jq
- git clone https://github.com/sstephenson/bats.git
- cd bats
- ./install.sh /usr
- cd ../test
- ./returnTest.bats
dependencies:
- compile
......@@ -35,7 +40,22 @@ testUbuntu:
stage: test
tags:
- ubuntu
- regular
script:
- echo "It works Ubuntu:16.04"
- apt-get update && apt-get install -y bats jq
- cd test
- ./returnTest.bats
dependencies:
- compile
testOpensuse:
stage: test
tags:
- opensuse
script:
- zypper -n update
- zypper -n install bats && zypper -n install jq
- cd test
- ./returnTest.bats
dependencies:
- compile
#!/usr/bin/env bats
function amount_users() {
obj=$(cat export.json | jq -r '.data.amount_users')
[[ "$obj" -eq "$obj" ]] && [[ "$obj" != "null" ]]
}
function mac_address() {
obj=$(cat export.json | jq -r '.data.mac_address')
[[ "$obj" =~ ^(..:){5}..$ ]] && [[ "$obj" != "null" ]]
}
function machine_type() {
obj=$(cat export.json | jq -r '.data.machine_type')
[[ "$obj" != "null" ]]
}
function memory() {
obj=$(cat export.json | jq -r '.data.memory')
[[ "$obj" -eq "$obj" ]] && [[ "$obj" != "null" ]]
}
function os_distro() {
obj=$(cat export.json | jq -r '.data.os_distro')
[[ "$obj" != "null" ]]
}
function os_kernel() {
obj=$(cat export.json | jq -r '.data.os_kernel')
[[ "$obj" != "null" ]]
}
function os_type() {
obj=$(cat export.json | jq -r '.data.os_type')
[[ "$obj" != "null" ]]
}
function processor() {
obj=$(cat export.json | jq -r '.data.processor')
[[ "$obj" != "null" ]]
}
setup() {
./../bin/agent-v0.0 | head -n -2 > export.json
[ -s export.json ]
cat export.json
}
teardown() {
rm -f export.json
}
@test "Amount Users" {
run amount_users
[ "$status" -eq 0 ]
}
@test "MAC" {
run mac_address
[ "$status" -eq 0 ]
}
@test "Machine Type" {
run machine_type
[ "$status" -eq 0 ]
}
@test "Memory" {
run memory
[ "$status" -eq 0 ]
}
@test "OS Distro" {
run os_distro
[ "$status" -eq 0 ]
}
@test "OS Kernel" {
run os_kernel
[ "$status" -eq 0 ]
}
@test "OS Type" {
run os_type
[ "$status" -eq 0 ]
}
@test "Processor" {
run processor
[ "$status" -eq 0 ]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment