36 lines
728 B
V
36 lines
728 B
V
module conf
|
|
|
|
struct SingleConf {
|
|
some_string string
|
|
}
|
|
|
|
struct SingleConfDefault {
|
|
some_string string = 'default'
|
|
}
|
|
|
|
fn test_string_present_no_default() {
|
|
conf := load<SingleConf>(default_path: 'test/string.toml')!
|
|
assert conf == SingleConf{
|
|
some_string: 'hi'
|
|
}
|
|
}
|
|
|
|
fn test_string_absent_no_default() {
|
|
conf := load<SingleConf>(default_path: 'test/empty.toml') or { return }
|
|
assert false
|
|
}
|
|
|
|
fn test_string_present_default() {
|
|
conf := load<SingleConfDefault>(default_path: 'test/string.toml')!
|
|
assert conf == SingleConfDefault{
|
|
some_string: 'hi'
|
|
}
|
|
}
|
|
|
|
fn test_string_absent_default() {
|
|
conf := load<SingleConfDefault>(default_path: 'test/empty.toml')!
|
|
assert conf == SingleConfDefault{
|
|
some_string: 'default'
|
|
}
|
|
}
|