/****************************************************************************** __ ____ __ / / ___ ____ _/ __/_____________ _/ /__ / / / _ \/ __ `/ /_/ ___/ ___/ __ `/ / _ \ / /___/ __/ /_/ / __(__ ) /__/ /_/ / / __/ /_____/\___/\__,_/_/ /____/\___/\__,_/_/\___/ (C)opyright 2026, Leafscale, LLC - https://www.leafscale.com Project: repoman Filename: tests/test_config_save.reef Authors: Chris Tusa License: Description: Tests: registry save semantics ******************************************************************************/ import config import test.framework import core.result_generic as rg import io.dir as iodir import io.file as iofile import sys.process as pr proc main() let runner = new framework.TestRunner() let tmp: string = "/tmp/repoman-test-save" let _w: int = pr.process_wait(pr.process_spawn("rm", ["-rf", tmp])) let _c: bool = iodir.create_dir_all(tmp) let cfg_path: string = tmp + "/repoman.toml" let reg: config.Registry = config.default_registry("/home/u") let r1 = config.save(reg, cfg_path) runner.assert_eq_bool(rg.is_ok(r1), true, "save returns Ok") runner.assert_eq_bool(iofile.fileExists(cfg_path), true, "target file exists") runner.assert_eq_bool(iofile.fileExists(cfg_path + ".tmp"), false, "tmp removed after rename") // Round-trip: read what we wrote let contents: string = iofile.readFile(cfg_path) let r2 = config.parse_registry(contents) runner.assert_eq_bool(rg.is_ok(r2), true, "saved file parses") if rg.is_ok(r2) let reg2 = rg.unwrap_ok(r2) runner.assert_eq_int(reg2.schema, 3, "schema after parse = 3 (migrated)") end if let _w2: int = pr.process_wait(pr.process_spawn("rm", ["-rf", tmp])) runner.report() end main