Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible test #293

Merged
merged 2 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pengwin-setup.d/ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# shellcheck source=/usr/local/pengwin-setup.d/common.sh
source "$(dirname "$0")/common.sh" "$@"

if (whiptail --title "ANSIBLE" --yesno "Would you like to download and install Ansible?" 8 55); then
if (confirm --title "ANSIBLE" --yesno "Would you like to download and install Ansible?" 8 55); then
echo "Installing ANSIBLE"
install_packages ansible
else
Expand Down
32 changes: 32 additions & 0 deletions tests/ansible.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

source commons.sh

function testMain() {
run_pengwinsetup autoinstall TOOLS ANSIBLE

# shellcheck disable=SC2041
for i in 'ansible' ; do
package_installed $i
assertTrue "package $i is not installed" "$?"
done

command -v /usr/bin/ansible
assertEquals "Ansible was not installed" "0" "$?"
assertEquals "Ansible was not installed" "1" "$(run_command_as_testuser /usr/bin/ansible --version | grep -c '2.9')"
}

function testUninstall() {
run_pengwinsetup autoinstall UNINSTALL ANSIBLE

# shellcheck disable=SC2041
for i in 'ansible' ; do
package_installed $i
assertFalse "package $i is not uninstalled" "$?"
done

command -v /usr/bin/ansible
assertEquals "Ansible was not uninstalled" "1" "$?"
}

source shunit2
4 changes: 4 additions & 0 deletions tests/commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ function run_test() {
function run_pengwinsetup() {
sudo su - -c "$(pwd)/run-pengwin-setup.sh $*" ${TEST_USER}
}

function run_command_as_testuser() {
sudo su - -c "$*" ${TEST_USER}
}
6 changes: 3 additions & 3 deletions tests/cpp-vs-clion_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ function testMain() {
assertTrue "package $i is not installed" "$?"
done

assertEquals "Cmake was not installed" "1" "$(/usr/bin/cmake --version | grep -c '3')"
assertEquals "Cmake was not installed" "1" "$(run_command_as_testuser /usr/bin/cmake --version | grep -c '3')"

if [[ "$(uname -m)" == "x86_64" ]] ; then
assertEquals "MS Cmake was not installed" "1" "$(/usr/local/bin/cmake --version | grep -c '3.17')"
assertEquals "MS Cmake was not installed" "1" "$(run_command_as_testuser /usr/local/bin/cmake --version | grep -c '3.17')"
fi

}

function testUninstall() {
Expand Down
2 changes: 1 addition & 1 deletion tests/dotnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function testMain() {
assertTrue "package $i is not installed" "$?"
done

assertEquals ".NET Core was not installed" "1" "$(/usr/bin/dotnet --version | grep -c '3.1')"
assertEquals ".NET Core was not installed" "1" "$(run_command_as_testuser /usr/bin/dotnet --version | grep -c '3.1')"

command -v /usr/bin/nuget
assertEquals "NUGet was not installed" "0" "$?"
Expand Down
1 change: 1 addition & 0 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -e

../pengwin-setup --noninteractive update

run_test ./ansible.sh
run_test ./fish.sh
run_test ./x410.sh
run_test ./rclocal.sh
Expand Down