diff --git a/src/toml.rs b/src/toml.rs index 95da2ae..6fbb000 100644 --- a/src/toml.rs +++ b/src/toml.rs @@ -255,7 +255,6 @@ mod tests { fn no_comments() { let out = format::(FormatOptions { comments: false, - indent: 0, .. FormatOptions::default() }); assert_str_eq!(&out, include_format_output!("1-no-comments.toml")); diff --git a/src/yaml.rs b/src/yaml.rs index 5b8dab9..eb3a15a 100644 --- a/src/yaml.rs +++ b/src/yaml.rs @@ -229,3 +229,26 @@ impl fmt::Display for PrintExpr { } } } + + +#[cfg(test)] +mod tests { + use crate::test_utils::{self, include_format_output}; + use super::{format, FormatOptions}; + use pretty_assertions::assert_str_eq; + + #[test] + fn default() { + let out = format::(FormatOptions::default()); + assert_str_eq!(&out, include_format_output!("1-default.yaml")); + } + + #[test] + fn no_comments() { + let out = format::(FormatOptions { + comments: false, + .. FormatOptions::default() + }); + assert_str_eq!(&out, include_format_output!("1-no-comments.yaml")); + } +} diff --git a/tests/format-output/1-default.yaml b/tests/format-output/1-default.yaml new file mode 100644 index 0000000..d3e17ec --- /dev/null +++ b/tests/format-output/1-default.yaml @@ -0,0 +1,43 @@ +# A sample configuration for our app. + +# Name of the website. +# +# Required! This value must be specified. +#site_name: + +# Configurations related to the HTTP communication. +http: + # The port the server will listen on. + # + # Can also be specified via environment variable `PORT`. + # + # Required! This value must be specified. + #port: + + headers: + # The header in which the reverse proxy specifies the username. + # + # Default value: x-username + #username: x-username + + # The header in which the reverse proxy specifies the display name. + # + # Default value: x-display-name + #display_name: x-display-name + + # The bind address of the server. Can be set to `0.0.0.0` for example, to + # allow other users of the network to access the server. + # + # Default value: 127.0.0.1 + #bind: 127.0.0.1 + +# Configuring the logging. +log: + # If set to `true`, the app will log to stdout. + # + # Default value: true + #stdout: true + + # If this is set, the app will write logs to the given file. Of course, + # the app has to have write access to that file. + #file: diff --git a/tests/format-output/1-no-comments.yaml b/tests/format-output/1-no-comments.yaml new file mode 100644 index 0000000..d2952aa --- /dev/null +++ b/tests/format-output/1-no-comments.yaml @@ -0,0 +1,10 @@ +#site_name: +http: + #port: + headers: + #username: x-username + #display_name: x-display-name + #bind: 127.0.0.1 +log: + #stdout: true + #file: