---

# Tests for base-packages role

- name: If user disable installation of packages, install nothing
  fail:
    msg: "User disable ipackage installation but Packages installed"
  when:
    - base_packages_test_disable_installation
    - base_packages_installed is defined

- debug:
    var: base_packages_install

- name: If packages list set by user, install it
  fail:
    msg: "If user define a package list, install these packages"
  when:
    - base_packages_test_with_user_list
    - ((base_packages_install.results is defined)
        and ("{{ base_packages_install.results[0].item | length != 2 }}"))
      or (base_packages_install.item is defined
        and ("{{ base_packages_install.item.split(',') | length != 2 }}"))

- debug:
    var: base_packages_install

- name: If not packages list set by user, install os default
  fail:
    msg: "Packages installed are differents than default os if no user setting"
  when:
    - base_packages_test_with_default_list
    - ((base_packages_install.results is defined)
        and ("{{
          (base_packages_install.results[0].item | length)
          != (base_packages_simples_list | length) }}"))
      or ((base_packages_install.item is defined)
        and ("{{
          (base_packages_install.item.split(',') | length)
          != (base_packages_simples_list | length) }}"))


---

# Tests for base-packages role

- name: If user disable installation of packages, install nothing
  fail:
    msg: "User disable package installation but Packages installed"
  when:
    - base_packages_test_disable_installation
  failed_when: "base_packages_installed is defined"

- name: If packages list set by user, install it
  fail:
    msg: "If user define a package list, install these packages"
  when:
    - base_packages_test_with_user_list
  failed_when: "
    (base_packages_install.item is defined
      and (base_packages_install.item.split(',') | length != 2 ))
    or (base_packages_install.results
      and (base_packages_install.results[0].item | length != 2 ))"

- name: If not packages list set by user, install os default
  fail:
    msg: "Packages installed are differents than default os if no user setting"
  when:
    - base_packages_test_with_default_list
  failed_when: "
    (base_packages_install.item is defined
      and ((base_packages_install.item.split(',') | length)
        != (base_packages_simples_list | length) ))
    or (base_packages_install.results is defined
      and ((base_packages_install.results[0].item | length)
        != (base_packages_simples_list | length) ))"


Split when into when and failed_when statements. Remove brace
Split when into when and failed_when statements. Remove brace
