aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-02-02 12:15:27 +0100
committerDaniel Mueller <deso@posteo.net>2021-01-10 17:37:52 -0800
commitaeaffebcde16db3fa505935771b19cbae9a6f658 (patch)
treec3d814c6ea865f74ac47f3c0d5c12571e603d40a
parentfadd56a14310aea6a3f2d86693aa8e1dd8c12b67 (diff)
downloadnitrocli-aeaffebcde16db3fa505935771b19cbae9a6f658.tar.gz
nitrocli-aeaffebcde16db3fa505935771b19cbae9a6f658.tar.bz2
Add config test case and example config file
This patch adds a simple configuration file that demonstrates the syntax and contains some documentation. We suggest to ship this file together with nitrocli and to install it e.g., in the /usr/share/doc/nitrocli directory. This patch also adds a simple test case that makes sure that the example file is parsed correctly.
-rw-r--r--doc/config.example.toml10
-rw-r--r--src/tests/run.rs12
2 files changed, 22 insertions, 0 deletions
diff --git a/doc/config.example.toml b/doc/config.example.toml
new file mode 100644
index 0000000..a427749
--- /dev/null
+++ b/doc/config.example.toml
@@ -0,0 +1,10 @@
+# This is an example configuration file for nitrocli. To use it, place it at
+# ${XDG_CONFIG_HOME}/nitrocli/config.toml, where XDG_CONFIG_HOME defaults to
+# ${HOME}.
+
+# The model to connect to (string, "pro" or "storage", default: not set).
+model = "pro"
+# Do not cache secrets (boolean, default: false).
+no_cache = true
+# The log level (integer, default: 0).
+verbosity = 2
diff --git a/src/tests/run.rs b/src/tests/run.rs
index 22e7004..597e400 100644
--- a/src/tests/run.rs
+++ b/src/tests/run.rs
@@ -17,6 +17,8 @@
// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
// *************************************************************************
+use std::path;
+
use super::*;
#[test]
@@ -108,3 +110,13 @@ fn version_option() {
test(&re, "--version");
test(&re, "-V");
}
+
+#[test]
+fn config_file() {
+ let config =
+ crate::config::read_config_file(&path::Path::new("doc/config.example.toml")).unwrap();
+
+ assert_eq!(Some(crate::args::DeviceModel::Pro), config.model);
+ assert_eq!(true, config.no_cache);
+ assert_eq!(2, config.verbosity);
+}