summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/jinja2_native_types/test_concatentation.yml
blob: 24a90381e129acc90f6f701e615a8cffa7712794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
- name: add two ints
  set_fact:
      integer_sum: "{{ i_one + i_two }}"

- assert:
    that:
        - 'integer_sum == 3'
        - 'integer_sum|type_debug == "int"'

- name: add casted string and int
  set_fact:
      integer_sum2: "{{ s_one|int + i_two }}"

- assert:
    that:
        - 'integer_sum2 == 3'
        - 'integer_sum2|type_debug == "int"'

- name: concatenate int and string
  set_fact:
      string_sum: "'{{ [i_one, s_two]|join('') }}'"

- assert:
    that:
        - string_sum == "'12'"
        - 'string_sum|type_debug in ["str", "unicode"]'

- name: add two lists
  set_fact:
      list_sum: "{{ list_one + list_two }}"

- assert:
    that:
        - 'list_sum == ["one", "two", "three", "four"]'
        - 'list_sum|type_debug == "list"'

- name: add two lists, multi expression
  set_fact:
      list_sum_multi: "{{ list_one }} + {{ list_two }}"

- assert:
    that:
        - 'list_sum_multi|type_debug in ["str", "unicode"]'

- name: add two dicts
  set_fact:
      dict_sum: "{{ dict_one + dict_two }}"
  ignore_errors: yes

- assert:
    that:
        - 'dict_sum is undefined'

- name: loop through list with strings
  set_fact:
      list_for_strings: "{% for x in list_one %}{{ x }}{% endfor %}"

- assert:
    that:
        - 'list_for_strings == "onetwo"'
        - 'list_for_strings|type_debug in ["str", "unicode"]'

- name: loop through list with int
  set_fact:
      list_for_int: "{% for x in list_one_int %}{{ x }}{% endfor %}"

- assert:
    that:
        - 'list_for_int == 1'
        - 'list_for_int|type_debug == "int"'

- name: loop through list with ints
  set_fact:
      list_for_ints: "{% for x in list_ints %}{{ x }}{% endfor %}"

- assert:
    that:
        - 'list_for_ints == 42'
        - 'list_for_ints|type_debug == "int"'

- name: loop through list to create a new list
  set_fact:
      list_from_list: "[{% for x in list_ints %}{{ x }},{% endfor %}]"

- assert:
    that:
        - 'list_from_list == [4, 2]'
        - 'list_from_list|type_debug == "list"'