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
|
/******************************************************************************
__ ____ __
/ / ___ ____ _/ __/_____________ _/ /__
/ / / _ \/ __ `/ /_/ ___/ ___/ __ `/ / _ \
/ /___/ __/ /_/ / __(__ ) /__/ /_/ / / __/
/_____/\___/\__,_/_/ /____/\___/\__,_/_/\___/
(C)opyright 2026, Leafscale, LLC - https://www.leafscale.com
Project: repoman
Filename: tests/test_profile_render.reef
Authors: Chris Tusa <chris.tusa@leafscale.com>
License: <see LICENSE file included with this source code>
Description: Tests: profile ${VAR} substitution at install time
******************************************************************************/
import profile
import test.framework
import core.str
proc main()
let runner = new framework.TestRunner()
let host = profile.HostFacts {
lan_ip: "192.168.168.124",
user: "ctusa",
home: "/home/ctusa"
}
// All three substitutions
let yaml: string = "config:\n environment.OLLAMA_HOST: \"http://\${HOST_LAN_IP}:11434\"\ndevices:\n state:\n source: \${HOME}/.ollama\n user: \${USER}\n"
let out = profile.render(yaml, host)
runner.assert_contains_string(out, "http://192.168.168.124:11434", "\${HOST_LAN_IP} substituted")
runner.assert_contains_string(out, "/home/ctusa/.ollama", "\${HOME} substituted")
runner.assert_contains_string(out, "user: ctusa", "\${USER} substituted")
runner.assert_eq_bool(false, str.contains(out, "\${HOST_LAN_IP}"), "no leftover \${HOST_LAN_IP}")
runner.assert_eq_bool(false, str.contains(out, "\${USER}"), "no leftover \${USER}")
runner.assert_eq_bool(false, str.contains(out, "\${HOME}"), "no leftover \${HOME}")
// No substitutions present — input is returned unchanged
let plain: string = "name: foo\nconfig: {}\n"
runner.assert_eq_string(profile.render(plain, host), plain, "no-substitution input passes through")
// Empty input
runner.assert_eq_string(profile.render("", host), "", "empty input")
runner.report()
end main
|