Skip to content

Commit 4348a53

Browse files
committed
test: test for boolean values and null values are not allowed
This is the test for #153 Signed-off-by: Rich Megginson <rmeggins@redhat.com>
1 parent c8de5eb commit 4348a53

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# SPDX-License-Identifier: MIT
2+
---
3+
- name: Test boolean and null values not allowed
4+
hosts: all
5+
tasks:
6+
- name: Validate no boolean true values for bootloader values
7+
block:
8+
- name: Try to pass boolean true for bootloader values
9+
include_role:
10+
name: linux-system-roles.bootloader
11+
vars:
12+
bootloader_settings:
13+
- kernel: ALL
14+
options:
15+
- name: valid_value_1
16+
value: "true"
17+
- name: somevalue_1
18+
value: yes # yamllint disable-line rule:truthy
19+
- kernel: ALL
20+
options:
21+
- name: valid_value_2
22+
value: "false"
23+
- name: somevalue_2
24+
value: on # yamllint disable-line rule:truthy
25+
26+
- name: Unreachable task
27+
fail:
28+
msg: UNREACH
29+
30+
rescue:
31+
- name: Verify that the task failed
32+
assert:
33+
that:
34+
- ansible_failed_result.msg == "Boolean and null values are not allowed for bootloader settings"
35+
36+
- name: Validate no boolean false values for bootloader values
37+
block:
38+
- name: Try to pass boolean false for bootloader values
39+
include_role:
40+
name: linux-system-roles.bootloader
41+
vars:
42+
bootloader_settings:
43+
- kernel: ALL
44+
options:
45+
- name: valid_value_1
46+
value: "true"
47+
- name: somevalue_1
48+
value: no # yamllint disable-line rule:truthy
49+
- kernel: ALL
50+
options:
51+
- name: valid_value_2
52+
value: "false"
53+
- name: somevalue_2
54+
value: off # yamllint disable-line rule:truthy
55+
56+
- name: Unreachable task
57+
fail:
58+
msg: UNREACH
59+
60+
rescue:
61+
- name: Verify that the task failed
62+
assert:
63+
that:
64+
- ansible_failed_result.msg == "Boolean and null values are not allowed for bootloader settings"
65+
66+
- name: Validate no boolean null values for bootloader values
67+
block:
68+
- name: Try to pass boolean null for bootloader values
69+
include_role:
70+
name: linux-system-roles.bootloader
71+
vars:
72+
bootloader_settings:
73+
- kernel: ALL
74+
options:
75+
- name: valid_value_1
76+
value: "null"
77+
- name: somevalue_1
78+
value: null
79+
- kernel: ALL
80+
options:
81+
- name: valid_value_2
82+
value: "somevalue"
83+
84+
- name: Unreachable task
85+
fail:
86+
msg: UNREACH
87+
88+
rescue:
89+
- name: Verify that the task failed
90+
assert:
91+
that:
92+
- ansible_failed_result.msg == "Boolean and null values are not allowed for bootloader settings"

0 commit comments

Comments
 (0)