From 2ac62203d50cb218473aba7aa7a37b700a329b85 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 27 Mar 2022 12:49:04 -0700 Subject: [PATCH] tests: add test for invalid config (#55) --- tests/test_global_opts.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_global_opts.rs b/tests/test_global_opts.rs index 59d6a2301..676cf528a 100644 --- a/tests/test_global_opts.rs +++ b/tests/test_global_opts.rs @@ -105,3 +105,21 @@ color="always""#, o 0000000000000000000000000000000000000000 "###); } + +#[test] +fn test_invalid_config() { + // Test that we get a reasonable error if the config is invalid (#55) + let test_env = TestEnvironment::default(); + + std::fs::write( + test_env.config_path(), + "[section]key = value-missing-quotes", + ) + .unwrap(); + let assert = test_env + .jj_cmd(test_env.env_root(), &["init", "repo"]) + .assert() + .failure(); + insta::assert_snapshot!(get_stdout_string(&assert), @"Invalid config: expected newline, found an identifier at line 1 column 10 in config.toml +"); +}