|
root / tests / test_setup_planner.reef
test_setup_planner.reef Reef 51 lines 2.0 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
42
43
44
45
46
47
48
49
50
/******************************************************************************
                __               ____                __   
               / /   ___  ____ _/ __/_____________ _/ /__ 
              / /   / _ \/ __ `/ /_/ ___/ ___/ __ `/ / _ \
             / /___/  __/ /_/ / __(__  ) /__/ /_/ / /  __/
            /_____/\___/\__,_/_/ /____/\___/\__,_/_/\___/ 

    (C)opyright 2026, Leafscale, LLC -  https://www.leafscale.com

    Project: repoman
   Filename: tests/test_setup_planner.reef
    Authors: Chris Tusa <chris.tusa@leafscale.com>
    License: <see LICENSE file included with this source code>
Description: Tests: setup stage planner
     
******************************************************************************/

import setup
import test.framework

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

    // Fresh host
    let fresh = setup.Environment {
        home_dir: "/home/ctusa", user: "ctusa",
        host_lan_ip: "192.168.168.42",
        incus_reachable: true,
        repoman_project_present: false
    }
    let stages = setup.plan_stages(fresh)
    runner.assert_eq_int(stages.length(), 2, "always 2 stages: incus_project + registry_defaults")
    runner.assert_eq_string(stages[0].id, "incus_project", "stage 0 = incus_project")
    runner.assert_eq_bool(stages[0].is_change, true, "incus_project will change on fresh host")
    runner.assert_eq_string(stages[1].id, "registry_defaults", "stage 1 = registry_defaults")
    runner.assert_eq_bool(stages[1].is_change, true, "registry_defaults always writes")

    // Already-set-up host
    let done = setup.Environment {
        home_dir: "/home/ctusa", user: "ctusa",
        host_lan_ip: "192.168.168.42",
        incus_reachable: true,
        repoman_project_present: true
    }
    let s2 = setup.plan_stages(done)
    runner.assert_eq_int(s2.length(), 2, "still 2 stages")
    runner.assert_eq_bool(s2[0].is_change, false, "incus_project no-op when present")

    runner.report()
end main