@@ -4,21 +4,25 @@ def test_pillar_using_cp_module(salt_master, salt_minion, salt_cli, tmp_path):
4
4
"*":
5
5
- my_pillar
6
6
"""
7
- my_pillar = """
8
- {{% set file_content = salt.cp.get_file_str("{}") %}}
9
- """ .format (
10
- str (tmp_path / "myfile.txt" )
11
- )
12
- my_file = """
13
- foobar
7
+ my_file = tmp_path / "my_file.txt"
8
+ my_file .write_text ("foobar" )
9
+ my_file_contents = my_file .read_text ()
10
+ my_pillar = f"""
11
+ {{%- set something = salt['cp.get_file_str']("{ str (my_file )} ") %}}
12
+ file_content: {{{{ something }}}}
14
13
"""
15
- (tmp_path / "myfile.txt" ).write_text (my_file )
16
14
with salt_master .pillar_tree .base .temp_file ("top.sls" , pillar_top ):
17
15
with salt_master .pillar_tree .base .temp_file ("my_pillar.sls" , my_pillar ):
18
- with salt_master .pillar_tree .base .temp_file ("my_pillar.sls" , my_pillar ):
19
- ret = salt_cli .run ("state.apply" , minion_tgt = salt_minion .id )
20
- assert ret .returncode == 1
21
- assert (
22
- ret .json ["no_|-states_|-states_|-None" ]["comment" ]
23
- == "No states found for this minion"
24
- )
16
+ ret = salt_cli .run ("state.apply" , minion_tgt = salt_minion .id )
17
+ assert ret .returncode == 1
18
+ assert (
19
+ ret .json ["no_|-states_|-states_|-None" ]["comment" ]
20
+ == "No states found for this minion"
21
+ )
22
+
23
+ pillar_ret = salt_cli .run (
24
+ "pillar.item" , "file_content" , minion_tgt = salt_minion .id
25
+ )
26
+ assert pillar_ret .returncode == 0
27
+
28
+ assert '"file_content": "foobar"' in pillar_ret .stdout
0 commit comments