module machine import os fn with_temp_config(name string) string { dir := os.join_path(os.temp_dir(), 'koh3_machine_${os.getpid()}_${name}') os.rmdir_all(dir) or {} return dir } // The settings file is machine-wide and lives outside every repo, so these // tests write into a temporary home instead. fn test_remote_settings_round_trip() { home := with_temp_config('remote') defer { os.rmdir_all(home) or {} } // load_remote reads the real machine config, so only the parse and the // shape are checked here. values := parse_config('# comment\nkind=folder\npath=/tmp/remote\n\n') assert values['kind'] == 'folder' assert values['path'] == '/tmp/remote' assert values.len == 2 } fn test_parse_config_ignores_junk_and_keeps_later_values() { values := parse_config(' # a comment kind=s3 endpoint = https://s3.fr-par.scw.cloud kind=folder ') assert values['kind'] == 'folder' assert values['endpoint'] == 'https://s3.fr-par.scw.cloud' assert values.len == 2 } fn test_config_paths_are_outside_the_repo() { assert config_dir().ends_with('.config/koh') assert config_path(remote_file).ends_with('.config/koh/remote') assert config_path(credentials_file).ends_with('.config/koh/credentials') }