|
root / tests / test_config_schema_v3.reef
test_config_schema_v3.reef Reef 42 lines 1.4 KB
 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
import config
import test.framework
import core.result_generic as rg
import core.str

proc main()
    let runner = new framework.TestRunner()

    // Build a schema-3 registry, serialize, parse round-trip
    let reg = config.Registry {
        schema:   3,
        host:     config.Host { lan_ip: "192.168.168.124" },
        output:   "quiet",
        defaults: config.Defaults {
            repos_root:    "~/repos",
            backup_root:   "/nfs/repos",
            logdir:        "~/.local/state/repoman",
            incus_project: "repoman",
            default_image: "images:ubuntu/26.04/cloud",
            profiles:      ["default"]
        },
        projects: new [config.Project](0)
    }

    let s = config.serialize_registry(reg)
    runner.assert_contains_string(s, "schema = 3", "writes schema = 3")
    runner.assert_contains_string(s, "[host]", "writes [host] block")
    runner.assert_contains_string(s, "lan_ip = \"192.168.168.124\"", "writes lan_ip")
    let neg = str.contains(s, "[defaults.llm]")
    runner.assert_eq_bool(neg, false, "does NOT write [defaults.llm]")

    let r2 = config.parse_registry(s)
    runner.assert_eq_bool(rg.is_ok(r2), true, "round-trip parses ok")
    if rg.is_ok(r2)
        let reg2 = rg.unwrap_ok(r2)
        runner.assert_eq_int(reg2.schema, 3, "round-trip schema = 3")
        runner.assert_eq_string(reg2.host.lan_ip, "192.168.168.124", "round-trip host.lan_ip")
    end if

    runner.report()
end main