This repository has been archived by the owner on Feb 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from ahelal/feature/cli_tests
Feature/cli tests
- Loading branch information
Showing
9 changed files
with
259 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Running advanced.sh" | ||
TEST_SHELL="${TEST_SHELL-/bin/sh}" | ||
|
||
if [ -f /etc/redhat-release ]; then | ||
yum update | ||
fi | ||
|
||
if [ -f /etc/lsb-release ]; then | ||
sudo apt-get -y install git | ||
fi | ||
|
||
## Setup config | ||
export SETUP_USER=kitchen | ||
# don't clone use local path | ||
export AVM_VERSION="local" | ||
export AVM_VERBOSE="v" | ||
|
||
## Link dir .avm/.source_git/ since we are running local | ||
mkdir -p /home/${SETUP_USER}/.avm/.source_git/ | ||
ln -sfn /avm /home/${SETUP_USER}/.avm/.source_git/ | ||
|
||
## Run the setup | ||
${TEST_SHELL} /avm/setup.sh | ||
|
||
## Run installation | ||
printf "\nRunning avm install cli (1)\n" | ||
/usr/local/bin/avm install -v 2.0.2.0 -l v2.0 -r /avm/test/integration/cli/requirements.txt | ||
|
||
printf "\nRunning avm install cli (2)\n" | ||
/usr/local/bin/avm install -v 2.1.1.0 -l v2.1 -t pip | ||
|
||
printf "\nRunning avm install cli (3)\n" | ||
/usr/local/bin/avm install --version devel --label devel --requirements /avm/test/integration/cli/requirements.txt -t git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# AWS python boto | ||
boto3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
if [ -f /etc/lsb-release ]; then | ||
# travis issue :( | ||
sudo locale-gen en_US.UTF-8 | ||
fi | ||
|
||
echo "Installing" | ||
sudo su -c /avm/test/integration/cli/install.sh kitchen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require_relative '../../helper_spec.rb' | ||
|
||
context 'Ansible binaries' do | ||
describe command 'command -v ansible' do | ||
it 'executes ansible' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
describe command 'command -v ansible-playbook' do | ||
it 'executes ansible-playbook' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
describe command 'command -v ansible-doc' do | ||
it 'executes ansible-doc' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
describe command 'command -v ansible-galaxy' do | ||
it 'executes ansible-galaxy' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
describe command 'command -v ansible-pull' do | ||
it 'executes ansible-pull' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
describe command 'command -v ansible-vault' do | ||
it 'executes ansible-vault' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
# describe command 'command -v ansible-console' do | ||
# let(:pre_command) { 'avm use v2.1' } | ||
# it 'executes ansible-console' do | ||
# expect(subject.exit_status).to eq 0 | ||
# end | ||
# end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require_relative '../../helper_spec.rb' | ||
|
||
context 'AVM activate' do | ||
describe command 'avm activate' do | ||
it 'prints arguments' do | ||
expect(subject.exit_status).to eq 1 | ||
expect(subject.stdout).to match('argument') | ||
end | ||
end | ||
|
||
describe command 'avm activate xxxx' do | ||
it 'pints installed version' do | ||
expect(subject.exit_status).to eq 1 | ||
expect(subject.stdout).to match('available') | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
require_relative '../../helper_spec.rb' | ||
|
||
context 'AVM commands' do | ||
describe command 'command -v avm' do | ||
it 'executes avm' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
describe command 'avm' do | ||
it 'no args prints usage' do | ||
expect(subject.exit_status).to eq 0 | ||
expect(subject.stdout).to match('Usage') | ||
end | ||
end | ||
|
||
describe command 'command -v ansible-vault' do | ||
it 'executes ansible-vault' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
end | ||
|
||
context 'AVM Manage' do | ||
|
||
describe command 'avm installed' do | ||
let(:pre_command) { 'avm use v2.1' } | ||
it 'shows version v2.1' do | ||
expect(subject.exit_status).to eq 0 | ||
expect(subject.stdout).to match('v2.1') | ||
end | ||
end | ||
|
||
describe command 'avm list' do | ||
it 'show installed version' do | ||
expect(subject.exit_status).to eq 0 | ||
expect(subject.stdout).to match("installed versions: '2.0.2.0' '2.1.1.0' 'devel' 'v2.0' 'v2.1'") | ||
end | ||
end | ||
|
||
describe command 'avm info' do | ||
let(:pre_command) { 'avm use v2.0' } | ||
it 'use v2.0' do | ||
expect(subject.exit_status).to eq 0 | ||
expect(subject.stdout).to match('v2.0') | ||
end | ||
end | ||
|
||
describe command 'ansible --version' do | ||
let(:pre_command) { 'avm use v2.0' } | ||
it 'version is set 2.0' do | ||
expect(subject.exit_status).to eq 0 | ||
expect(subject.stdout).to match('ansible 2.0') | ||
end | ||
end | ||
|
||
describe command 'avm info' do | ||
let(:pre_command) { 'avm use v2.0' } | ||
it 'use v1' do | ||
expect(subject.exit_status).to eq 0 | ||
expect(subject.stdout).to match('v2.0') | ||
end | ||
end | ||
|
||
describe command 'avm path v2.0' do | ||
it 'print the correct v2.0 path ' do | ||
expect(subject.exit_status).to eq 0 | ||
expect(subject.stdout).to match('/home/kitchen/.avm/v2.0/venv/bin/') | ||
end | ||
end | ||
|
||
describe command 'avm path v2.1' do | ||
it 'print the correct v2.1 path ' do | ||
expect(subject.exit_status).to eq 0 | ||
expect(subject.stdout).to match('/home/kitchen/.avm/v2.1/venv/bin/') | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
require_relative '../../helper_spec.rb' | ||
|
||
context 'Directory stucture for V2.0' do | ||
|
||
describe command '/home/kitchen/.avm/v2.0/venv/bin/python -c "import boto3"' do | ||
it 'does have boto installed' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
describe file('/home/kitchen/.avm/v2.0/ansible/.git') do | ||
it 'does not have .git' do | ||
should_not exist | ||
end | ||
end | ||
end | ||
|
||
context 'Directory stucture for V2.1' do | ||
describe command '/home/kitchen/.avm/v2.1/venv/bin/python -c "import boto3"' do | ||
it 'does not have boto installed' do | ||
expect(subject.exit_status).to eq 1 | ||
end | ||
end | ||
|
||
describe file('/home/kitchen/.avm/v2.1/ansible/.git') do | ||
it 'does not have .git' do | ||
should_not exist | ||
end | ||
end | ||
end | ||
|
||
context 'Directory stucture for devel' do | ||
describe command ' /home/kitchen/.avm/devel/venv/bin/python -c "import boto3"' do | ||
it 'does have boto installed' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
describe file('/home/kitchen/.avm/.source_git/ansible/.git') do | ||
it 'has .git' do | ||
should exist | ||
end | ||
end | ||
|
||
describe command 'cd /home/kitchen/.avm/.source_git/ansible/;git branch' do | ||
it 'is devel' do | ||
expect(subject.stdout).to match('devel') | ||
end | ||
end | ||
|
||
end | ||
|
||
context 'Directory stucture venv' do | ||
describe file('/home/kitchen/.avm/') do | ||
it 'has right perm' do | ||
should exist | ||
should be_directory | ||
should be_mode 755 | ||
should be_owned_by 'kitchen' | ||
end | ||
end | ||
end |