-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
settings: own StackedConfig by UserSettings, migrate tests to use con…
…fig layer UserSettings::get_*() will be changed to look up a merged value from StackedConfig, not from a merged config::Value. This will help migrate away from the config crate. Not all tests are ported to ConfigLayer::parse() because it seemed a bit odd to format!() a TOML document and parse it to build a table of configuration variables.
- Loading branch information
Showing
10 changed files
with
133 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,15 @@ | |
// limitations under the License. | ||
|
||
use futures::StreamExt as _; | ||
use indoc::indoc; | ||
use itertools::Itertools; | ||
use jj_lib::backend::ChangeId; | ||
use jj_lib::backend::MillisSinceEpoch; | ||
use jj_lib::backend::Signature; | ||
use jj_lib::backend::Timestamp; | ||
use jj_lib::config::ConfigLayer; | ||
use jj_lib::config::ConfigSource; | ||
use jj_lib::config::StackedConfig; | ||
use jj_lib::matchers::EverythingMatcher; | ||
use jj_lib::merged_tree::MergedTree; | ||
use jj_lib::repo::Repo; | ||
|
@@ -152,13 +156,17 @@ fn test_rewrite(backend: TestRepoBackend) { | |
], | ||
); | ||
|
||
let config = config::Config::builder() | ||
.set_override("user.name", "Rewrite User") | ||
.unwrap() | ||
.set_override("user.email", "[email protected]") | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
let mut config = StackedConfig::empty(); | ||
config.add_layer( | ||
ConfigLayer::parse( | ||
ConfigSource::User, | ||
indoc! {" | ||
user.name = 'Rewrite User' | ||
user.email = '[email protected]' | ||
"}, | ||
) | ||
.unwrap(), | ||
); | ||
let rewrite_settings = UserSettings::from_config(config); | ||
let mut tx = repo.start_transaction(&settings); | ||
let rewritten_commit = tx | ||
|
@@ -203,8 +211,7 @@ fn test_rewrite(backend: TestRepoBackend) { | |
#[test_case(TestRepoBackend::Local ; "local backend")] | ||
#[test_case(TestRepoBackend::Git ; "git backend")] | ||
fn test_rewrite_update_missing_user(backend: TestRepoBackend) { | ||
let missing_user_settings = | ||
UserSettings::from_config(config::Config::builder().build().unwrap()); | ||
let missing_user_settings = UserSettings::from_config(StackedConfig::empty()); | ||
let test_repo = TestRepo::init_with_backend(backend); | ||
let repo = &test_repo.repo; | ||
|
||
|
@@ -223,13 +230,17 @@ fn test_rewrite_update_missing_user(backend: TestRepoBackend) { | |
assert_eq!(initial_commit.committer().name, ""); | ||
assert_eq!(initial_commit.committer().email, ""); | ||
|
||
let config = config::Config::builder() | ||
.set_override("user.name", "Configured User") | ||
.unwrap() | ||
.set_override("user.email", "[email protected]") | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
let mut config = StackedConfig::empty(); | ||
config.add_layer( | ||
ConfigLayer::parse( | ||
ConfigSource::User, | ||
indoc! {" | ||
user.name = 'Configured User' | ||
user.email = '[email protected]' | ||
"}, | ||
) | ||
.unwrap(), | ||
); | ||
let settings = UserSettings::from_config(config); | ||
let rewritten_commit = tx | ||
.repo_mut() | ||
|
@@ -257,11 +268,15 @@ fn test_rewrite_resets_author_timestamp(backend: TestRepoBackend) { | |
|
||
// Create discardable commit | ||
let initial_timestamp = "2001-02-03T04:05:06+07:00"; | ||
let config = testutils::base_config() | ||
.set_override("debug.commit-timestamp", initial_timestamp) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
let mut config = testutils::base_user_config(); | ||
config.add_layer(ConfigLayer::with_data( | ||
ConfigSource::User, | ||
config::Config::builder() | ||
.set_override("debug.commit-timestamp", initial_timestamp) | ||
.unwrap() | ||
.build() | ||
.unwrap(), | ||
)); | ||
let settings = UserSettings::from_config(config); | ||
let mut tx = repo.start_transaction(&settings); | ||
let initial_commit = tx | ||
|
@@ -281,11 +296,15 @@ fn test_rewrite_resets_author_timestamp(backend: TestRepoBackend) { | |
|
||
// Rewrite discardable commit to no longer be discardable | ||
let new_timestamp_1 = "2002-03-04T05:06:07+08:00"; | ||
let config = testutils::base_config() | ||
.set_override("debug.commit-timestamp", new_timestamp_1) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
let mut config = testutils::base_user_config(); | ||
config.add_layer(ConfigLayer::with_data( | ||
ConfigSource::User, | ||
config::Config::builder() | ||
.set_override("debug.commit-timestamp", new_timestamp_1) | ||
.unwrap() | ||
.build() | ||
.unwrap(), | ||
)); | ||
let settings = UserSettings::from_config(config); | ||
let rewritten_commit_1 = tx | ||
.repo_mut() | ||
|
@@ -304,11 +323,15 @@ fn test_rewrite_resets_author_timestamp(backend: TestRepoBackend) { | |
|
||
// Rewrite non-discardable commit | ||
let new_timestamp_2 = "2003-04-05T06:07:08+09:00"; | ||
let config = testutils::base_config() | ||
.set_override("debug.commit-timestamp", new_timestamp_2) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
let mut config = testutils::base_user_config(); | ||
config.add_layer(ConfigLayer::with_data( | ||
ConfigSource::User, | ||
config::Config::builder() | ||
.set_override("debug.commit-timestamp", new_timestamp_2) | ||
.unwrap() | ||
.build() | ||
.unwrap(), | ||
)); | ||
let settings = UserSettings::from_config(config); | ||
let rewritten_commit_2 = tx | ||
.repo_mut() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.