module conf struct SingleConf { some_string string } struct SingleConfDefault { some_string string = 'default' } fn test_string_present_no_default() { conf := load(default_path: 'test/string.toml')! assert conf == SingleConf{ some_string: 'hi' } conf2 := load(default_path: 'test/string_empty.toml')! assert conf2 == SingleConf{ some_string: '' } } fn test_string_present_no_default_env() { mut conf := load( default_path: 'test/string.toml' env: { 'SOME_STRING': 'env' } )! assert conf == SingleConf{ some_string: 'env' } conf = load( default_path: 'test/string.toml' env: { 'SOME_STRING': '' } )! assert conf == SingleConf{ some_string: '' } conf = load( default_path: 'test/string.toml' env: { 'TEST_SOME_STRING': 'env' } prefix: 'TEST_' )! assert conf == SingleConf{ some_string: 'env' } } fn test_string_absent_no_default() { conf := load(default_path: 'test/empty.toml') or { return } assert false } fn test_string_absent_no_default_env() { mut conf := load( default_path: 'test/string.toml' env: { 'SOME_STRING': 'env' } )! assert conf == SingleConf{ some_string: 'env' } conf = load( default_path: 'test/string.toml' env: { 'SOME_STRING': '' } )! assert conf == SingleConf{ some_string: '' } conf = load( default_path: 'test/string.toml' env: { 'TEST_SOME_STRING': 'env' } prefix: 'TEST_' )! assert conf == SingleConf{ some_string: 'env' } } fn test_string_present_default() { conf := load(default_path: 'test/string.toml')! assert conf == SingleConfDefault{ some_string: 'hi' } } fn test_string_present_default_env() { mut conf := load( default_path: 'test/string.toml' env: { 'SOME_STRING': 'env' } )! assert conf == SingleConfDefault{ some_string: 'env' } conf = load( default_path: 'test/string.toml' env: { 'SOME_STRING': '' } )! assert conf == SingleConfDefault{ some_string: '' } conf = load( default_path: 'test/string.toml' env: { 'TEST_SOME_STRING': 'env' } prefix: 'TEST_' )! assert conf == SingleConfDefault{ some_string: 'env' } } fn test_string_absent_default() { conf := load(default_path: 'test/empty.toml')! assert conf == SingleConfDefault{ some_string: 'default' } } fn test_string_absent_default_env() { mut conf := load( default_path: 'test/empty.toml' env: { 'SOME_STRING': 'env' } )! assert conf == SingleConfDefault{ some_string: 'env' } conf = load( default_path: 'test/empty.toml' env: { 'SOME_STRING': '' } )! assert conf == SingleConfDefault{ some_string: '' } conf = load( default_path: 'test/empty.toml' env: { 'TEST_SOME_STRING': 'env' } prefix: 'TEST_' )! assert conf == SingleConfDefault{ some_string: 'env' } }