settings_test.v

1.2 KB · raw

1module machine23import os45fn with_temp_config(name string) string {6	dir := os.join_path(os.temp_dir(), 'koh3_machine_${os.getpid()}_${name}')7	os.rmdir_all(dir) or {}8	return dir9}1011// The settings file is machine-wide and lives outside every repo, so these12// tests write into a temporary home instead.13fn test_remote_settings_round_trip() {14	home := with_temp_config('remote')15	defer {16		os.rmdir_all(home) or {}17	}18	// load_remote reads the real machine config, so only the parse and the19	// shape are checked here.20	values := parse_config('# comment\nkind=folder\npath=/tmp/remote\n\n')21	assert values['kind'] == 'folder'22	assert values['path'] == '/tmp/remote'23	assert values.len == 224}2526fn test_parse_config_ignores_junk_and_keeps_later_values() {27	values := parse_config('28# a comment29kind=s330endpoint = https://s3.fr-par.scw.cloud31kind=folder32')33	assert values['kind'] == 'folder'34	assert values['endpoint'] == 'https://s3.fr-par.scw.cloud'35	assert values.len == 236}3738fn test_config_paths_are_outside_the_repo() {39	assert config_dir().ends_with('.config/koh')40	assert config_path(remote_file).ends_with('.config/koh/remote')41	assert config_path(credentials_file).ends_with('.config/koh/credentials')42}