/****************************************************************************** __ ____ __ / / ___ ____ _/ __/_____________ _/ /__ / / / _ \/ __ `/ /_/ ___/ ___/ __ `/ / _ \ / /___/ __/ /_/ / __(__ ) /__/ /_/ / / __/ /_____/\___/\__,_/_/ /____/\___/\__,_/_/\___/ (C)opyright 2026, Leafscale, LLC - https://www.leafscale.com Project: repoman Filename: tests/test_config_io.reef Authors: Chris Tusa License: Description: Tests: registry file I/O ******************************************************************************/ import config import test.framework import core.result as rg import io.dir as iodir import io.file as iofile import sys.process as pr proc main() let runner = new framework.TestRunner() // Set up a fresh temp dir as fake $HOME let tmp: string = "/tmp/repoman-test-load-init" // Wipe and recreate let _w: int = pr.process_wait(pr.process_spawn("rm", ["-rf", tmp])) let _c = iodir.create_dir_all(tmp) // First call: no .config/repoman/repoman.toml exists → init writes default let r1 = config.load_or_init(tmp) runner.assert_eq_bool(rg.is_ok(r1), true, "load_or_init creates default") if rg.is_ok(r1) let reg = rg.unwrap_ok(r1) runner.assert_eq_int(reg.schema, 3, "default schema = 3") runner.assert_eq_int(reg.projects.length(), 0, "default has no projects") runner.assert_eq_string(reg.defaults.incus_project, "repoman", "default incus_project") end if // The file should now exist on disk. let cfg_path: string = tmp + "/.config/repoman/repoman.toml" runner.assert_eq_bool(iofile.fileExists(cfg_path), true, "registry file written") // Second call: should load the existing file. let r2 = config.load_or_init(tmp) runner.assert_eq_bool(rg.is_ok(r2), true, "second load reads existing") // Cleanup let _w2: int = pr.process_wait(pr.process_spawn("rm", ["-rf", tmp])) runner.report() end main