mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 07:14:38 +00:00
sign: add tests for the jj sign
command
These changes were taken from #3142.
This commit is contained in:
parent
332902e5fe
commit
e4df7b12cc
2 changed files with 118 additions and 0 deletions
|
@ -63,6 +63,7 @@ mod test_revset_output;
|
|||
mod test_root;
|
||||
mod test_shell_completion;
|
||||
mod test_show_command;
|
||||
mod test_sign_command;
|
||||
mod test_simplify_parents_command;
|
||||
mod test_sparse_command;
|
||||
mod test_split_command;
|
||||
|
|
117
cli/tests/test_sign_command.rs
Normal file
117
cli/tests/test_sign_command.rs
Normal file
|
@ -0,0 +1,117 @@
|
|||
// Copyright 2023 The Jujutsu Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::common::TestEnvironment;
|
||||
|
||||
#[test]
|
||||
fn test_sign() {
|
||||
let test_env = TestEnvironment::default();
|
||||
|
||||
test_env.add_config(
|
||||
r#"
|
||||
[signing]
|
||||
show-signatures = true
|
||||
sign-all = false
|
||||
backend = "test"
|
||||
"#,
|
||||
);
|
||||
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "init"]);
|
||||
|
||||
let show_no_sig = test_env.jj_cmd_success(&repo_path, &["show", "-r", "@-"]);
|
||||
|
||||
insta::assert_snapshot!(show_no_sig, @r###"
|
||||
Commit ID: be2ecf9517746b48c24d5bc0750b2b4adb51121d
|
||||
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu
|
||||
Author: Test User <test.user@example.com> (2001-02-03 08:05:08)
|
||||
Committer: Test User <test.user@example.com> (2001-02-03 08:05:08)
|
||||
|
||||
init
|
||||
"###);
|
||||
|
||||
let (_, stderr) = test_env.jj_cmd_ok(&repo_path, &["sign", "-r", "@-"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Rebased 1 descendant commits
|
||||
Working copy now at: rlvkpnrz b162855d (empty) (no description set)
|
||||
Parent commit : qpvuntsm [✓︎] 5aab9df2 (empty) init
|
||||
Commit was signed: qpvuntsm [✓︎] 5aab9df2 (empty) init
|
||||
"###);
|
||||
|
||||
let show_with_sig = test_env.jj_cmd_success(&repo_path, &["show", "-r", "@-"]);
|
||||
|
||||
insta::assert_snapshot!(show_with_sig, @r###"
|
||||
Commit ID: 5aab9df27eb838f225ae554edd56a11b3ecd13df
|
||||
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu
|
||||
Author: Test User <test.user@example.com> (2001-02-03 04:05:07.000 +07:00)
|
||||
Committer: Test User <test.user@example.com> (2001-02-03 04:05:10.000 +07:00)
|
||||
Signature: Good mock signature
|
||||
|
||||
init
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sig_drop() {
|
||||
let test_env = TestEnvironment::default();
|
||||
|
||||
test_env.add_config(
|
||||
r#"
|
||||
[signing]
|
||||
show-signatures = true
|
||||
sign-all = false
|
||||
backend = "test"
|
||||
"#,
|
||||
);
|
||||
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "init"]);
|
||||
|
||||
let show_no_sig = test_env.jj_cmd_success(&repo_path, &["show", "-r", "@-"]);
|
||||
insta::assert_snapshot!(show_no_sig, @r###"
|
||||
Commit ID: be2ecf9517746b48c24d5bc0750b2b4adb51121d
|
||||
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu
|
||||
Author: Test User <test.user@example.com> (2001-02-03 08:05:08)
|
||||
Committer: Test User <test.user@example.com> (2001-02-03 08:05:08)
|
||||
|
||||
init
|
||||
"###);
|
||||
|
||||
test_env.jj_cmd_ok(&repo_path, &["sign", "-r", "@-"]);
|
||||
|
||||
let show_with_sig = test_env.jj_cmd_success(&repo_path, &["show", "-r", "@-"]);
|
||||
insta::assert_snapshot!(show_with_sig, @r###"
|
||||
Commit ID: 5aab9df27eb838f225ae554edd56a11b3ecd13df
|
||||
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu
|
||||
Author: Test User <test.user@example.com> (2001-02-03 04:05:07.000 +07:00)
|
||||
Committer: Test User <test.user@example.com> (2001-02-03 04:05:10.000 +07:00)
|
||||
Signature: Good mock signature
|
||||
|
||||
init
|
||||
"###);
|
||||
|
||||
test_env.jj_cmd_ok(&repo_path, &["sign", "-r", "@-", "--drop"]);
|
||||
|
||||
let show_with_sig = test_env.jj_cmd_success(&repo_path, &["show", "-r", "@-"]);
|
||||
insta::assert_snapshot!(show_with_sig, @r###"
|
||||
Commit ID: a37490e69293173538209a45786d10c63c8960d7
|
||||
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu
|
||||
Author: Test User <test.user@example.com> (2001-02-03 04:05:07.000 +07:00)
|
||||
Committer: Test User <test.user@example.com> (2001-02-03 04:05:12.000 +07:00)
|
||||
|
||||
init
|
||||
"###);
|
||||
}
|
Loading…
Reference in a new issue