From 7190ce1864ce62b71e9dc2d5aeb1d6bf017adf1c Mon Sep 17 00:00:00 2001 From: Paul Montero Date: Tue, 19 Sep 2017 15:09:22 -0500 Subject: [PATCH] Setup assertions, run them after the installation --- tests/post_tasks.yml | 35 +++++++++++++++++++++++++++++++ tests/{test_root.yml => root.yml} | 9 +++++++- tests/{test_user.yml => user.yml} | 7 +++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/post_tasks.yml rename tests/{test_root.yml => root.yml} (68%) rename tests/{test_user.yml => user.yml} (66%) diff --git a/tests/post_tasks.yml b/tests/post_tasks.yml new file mode 100644 index 0000000..750f8a1 --- /dev/null +++ b/tests/post_tasks.yml @@ -0,0 +1,35 @@ +--- +post_tasks: + - name: Check that ruby exists + command: ruby -v + register: check_ruby + - assert: + that: + - "check_ruby == 'ruby'" + - "check_ruby.rc == 0 " + msg: No ruby test pass + + - name: Check default ruby + shell: ~/.rvm/wrappers/default/ruby -v | cut -c1-10 + register: check_ruby_default + - assert: + that: + - "check_ruby_default.stdout == 'ruby 2.3.1'" + msg: Default ruby test pass + + - name: Check multiple rubies + command: ls ~/.rvm/rubies + register: check_ruby_multiple + - assert: + that: + - "ruby-2.2.5' in check_ruby_multiple.stdout" + - "ruby-2.3.1' in check_ruby_multiple.stdout" + msg: Multiple rubies test pass + + - name: Check bundler symlinked on system path + shell: ls ~/.rvm/wrappers/default/ |grep 'bundler' + register: check_ruby_bundler + - assert: + that: + - "check_ruby_bundler.stdout == 'bundler' " + msg: Bundler symlinked on system path test pass diff --git a/tests/test_root.yml b/tests/root.yml similarity index 68% rename from tests/test_root.yml rename to tests/root.yml index 789a0b0..32dc5b3 100644 --- a/tests/test_root.yml +++ b/tests/root.yml @@ -4,9 +4,16 @@ vars: rvm1_user: root rvm1_install_flags: '--auto-dotfiles' + rvm1_install_path: '/home/{{ rvm1_user }}/.rvm' rvm1_rubies: - 'ruby-2.2.5' - 'ruby-2.3.1' - rvm1_install_path: '/home/{{ rvm1_user }}/.rvm' roles: - role: rvm1-ansible + +# Asserts tasks +- hosts: all + gather_facts: false + tasks: + - name: Assert tasks + include: assertetions.yml diff --git a/tests/test_user.yml b/tests/user.yml similarity index 66% rename from tests/test_user.yml rename to tests/user.yml index 05041f8..dec998f 100644 --- a/tests/test_user.yml +++ b/tests/user.yml @@ -10,3 +10,10 @@ roles: - role: rvm1-ansible become: yes + +# Asserts tasks +- hosts: all + gather_facts: false + tasks: + - name: Assert tasks + include: assertions.yml