From a0593e3aa9b19b9ca3c3881cbe0d9d207fe46d2c Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 26 Nov 2024 07:48:30 +0000 Subject: refactor: err msgs 'cannot' > 'failed to' in nearly all cases 'cannot' was used when an action was tried and failed. 'failed to' is strictly better because: * just because the action didn't work that time doesnt mean it cannot work * it is better at drawing the users attention to a problem --- tests/git_remote_nostr/main.rs | 2 +- tests/ngit_init.rs | 2 +- tests/ngit_login.rs | 8 ++++---- tests/ngit_pull.rs | 4 +++- tests/ngit_push.rs | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/git_remote_nostr/main.rs b/tests/git_remote_nostr/main.rs index f749c7f..84e66bd 100644 --- a/tests/git_remote_nostr/main.rs +++ b/tests/git_remote_nostr/main.rs @@ -43,7 +43,7 @@ fn set_git_nostr_login_config(test_repo: &GitTestRepo) -> Result<()> { let mut config = test_repo .git_repo .config() - .context("cannot open git config")?; + .context("failed to open git config")?; config.set_str("nostr.nsec", TEST_KEY_2_NSEC)?; config.set_str("nostr.npub", TEST_KEY_2_NPUB)?; config.set_str("user.name", "test name")?; diff --git a/tests/ngit_init.rs b/tests/ngit_init.rs index 1183b3c..4302524 100644 --- a/tests/ngit_init.rs +++ b/tests/ngit_init.rs @@ -309,7 +309,7 @@ mod when_repo_not_previously_claimed { let cli_tester_handle = std::thread::spawn(move || -> Result<()> { let yaml_path = git_repo.dir.join("maintainers.yaml"); let mut file = std::fs::File::create(&yaml_path) - .expect("cannot create maintainers.yaml file"); + .expect("failed to create maintainers.yaml file"); write!( file, "\ diff --git a/tests/ngit_login.rs b/tests/ngit_login.rs index c928cc4..4cfe4e6 100644 --- a/tests/ngit_login.rs +++ b/tests/ngit_login.rs @@ -128,7 +128,7 @@ mod with_relays { p.expect("searching for profile...\r\n")?; - p.expect("cannot extract account name from account metadata...\r\n")?; + p.expect("failed to extract account name from account metadata...\r\n")?; p.expect_end_with( format!("logged in as {}\r\n", TEST_KEY_1_NPUB).as_str(), @@ -618,7 +618,7 @@ mod with_relays { p.expect("searching for profile...\r\n")?; - p.expect("cannot find profile...\r\n")?; + p.expect("failed to find profile...\r\n")?; p.expect_end_with(format!("logged in as {TEST_KEY_1_NPUB}\r\n").as_str())?; for p in [51, 52] { @@ -682,7 +682,7 @@ mod with_relays { p.expect("searching for profile...\r\n")?; - p.expect("cannot find your relay list. consider using another nostr client to create one to enhance your nostr experience.\r\n")?; + p.expect("failed to find your relay list. consider using another nostr client to create one to enhance your nostr experience.\r\n")?; p.expect_end_with("logged in as fred\r\n")?; for p in [51, 52] { @@ -932,7 +932,7 @@ mod with_offline_flag { p.expect_input(EXPECTED_NSEC_PROMPT)? // this behaviour is intentional. rejecting the response with dialoguer // hides the original input from the user so they - // cannot see the mistake they made. + // failed to see the mistake they made. .succeeds_with(TEST_INVALID_NSEC)?; p.expect_input(invalid_nsec_response)? diff --git a/tests/ngit_pull.rs b/tests/ngit_pull.rs index 6637859..2fb9229 100644 --- a/tests/ngit_pull.rs +++ b/tests/ngit_pull.rs @@ -96,7 +96,9 @@ mod when_branch_doesnt_exist { let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - p.expect("Error: cannot find proposal that matches the current branch name\r\n")?; + p.expect( + "Error: failed to find proposal that matches the current branch name\r\n", + )?; p.expect_end()?; diff --git a/tests/ngit_push.rs b/tests/ngit_push.rs index f37e027..d4b3894 100644 --- a/tests/ngit_push.rs +++ b/tests/ngit_push.rs @@ -58,7 +58,7 @@ mod when_proposal_isnt_associated_with_branch_name { p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here p.expect_end_with( - "Error: cannot find proposal that matches the current branch name\r\n", + "Error: failed to find proposal that matches the current branch name\r\n", )?; for p in [51, 52, 53, 55, 56] { relay::shutdown_relay(8000 + p)?; -- cgit v1.2.3