2020-12-12 08:00:42 +00:00
|
|
|
// Copyright 2020 Google LLC
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2022-03-30 17:47:11 +00:00
|
|
|
use crate::common::TestEnvironment;
|
|
|
|
|
|
|
|
pub mod common;
|
2020-12-12 08:00:42 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn smoke_test() {
|
2022-01-16 06:06:12 +00:00
|
|
|
let test_env = TestEnvironment::default();
|
2022-03-26 21:06:48 +00:00
|
|
|
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
2020-12-12 08:00:42 +00:00
|
|
|
|
2022-01-16 06:06:12 +00:00
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2020-12-12 08:00:42 +00:00
|
|
|
// Check the output of `jj status` right after initializing repo
|
2022-03-26 21:06:48 +00:00
|
|
|
let stdout = test_env.jj_cmd_success(&repo_path, &["status"]);
|
|
|
|
insta::assert_snapshot!(stdout, @r###"
|
2022-05-17 17:22:46 +00:00
|
|
|
Parent commit: 000000000000 (no description set)
|
|
|
|
Working copy : 230dd059e1b0 (no description set)
|
2022-03-06 03:32:20 +00:00
|
|
|
The working copy is clean
|
|
|
|
"###);
|
2020-12-12 08:00:42 +00:00
|
|
|
|
|
|
|
// Write some files and check the output of `jj status`
|
|
|
|
std::fs::write(repo_path.join("file1"), "file1").unwrap();
|
|
|
|
std::fs::write(repo_path.join("file2"), "file2").unwrap();
|
|
|
|
std::fs::write(repo_path.join("file3"), "file3").unwrap();
|
|
|
|
|
2022-03-05 06:33:15 +00:00
|
|
|
// The working copy's ID should have changed
|
2022-03-26 21:06:48 +00:00
|
|
|
let stdout = test_env.jj_cmd_success(&repo_path, &["status"]);
|
|
|
|
insta::assert_snapshot!(stdout, @r###"
|
2022-05-17 17:22:46 +00:00
|
|
|
Parent commit: 000000000000 (no description set)
|
|
|
|
Working copy : d38745675403 (no description set)
|
2022-03-06 03:32:20 +00:00
|
|
|
Working copy changes:
|
|
|
|
A file1
|
|
|
|
A file2
|
|
|
|
A file3
|
|
|
|
"###);
|
2020-12-12 08:00:42 +00:00
|
|
|
|
|
|
|
// Running `jj status` again gives the same output
|
2022-03-26 21:06:48 +00:00
|
|
|
let stdout_again = test_env.jj_cmd_success(&repo_path, &["status"]);
|
|
|
|
assert_eq!(stdout_again, stdout);
|
2020-12-12 08:00:42 +00:00
|
|
|
|
|
|
|
// Add a commit description
|
2022-03-26 21:06:48 +00:00
|
|
|
let stdout = test_env.jj_cmd_success(&repo_path, &["describe", "-m", "add some files"]);
|
2022-04-28 23:32:18 +00:00
|
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
|
|
Working copy now at: 701b3d5a2eb3 add some files
|
|
|
|
"###);
|
2020-12-12 08:00:42 +00:00
|
|
|
|
|
|
|
// Close the commit
|
2022-03-26 21:06:48 +00:00
|
|
|
let stdout = test_env.jj_cmd_success(&repo_path, &["close"]);
|
2022-04-28 23:32:18 +00:00
|
|
|
insta::assert_snapshot!(stdout, @r###"
|
2022-05-17 17:22:46 +00:00
|
|
|
Working copy now at: a13f828fab1a (no description set)
|
2022-04-28 23:32:18 +00:00
|
|
|
"###);
|
2020-12-12 08:00:42 +00:00
|
|
|
}
|