Skip to content
This repository was archived by the owner on Dec 22, 2024. It is now read-only.

Commit d1bb5f5

Browse files
committed
Adjust tests and calls to set_name
1 parent 102fadf commit d1bb5f5

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

Diff for: Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tm"
33
description = "tmux helper"
4-
version = "0.9.1"
4+
version = "0.9.2"
55
edition = "2021"
66
authors = ["Jörg Jaspert <[email protected]>"]
77
license = "BSD-2-Clause"

Diff for: src/main.rs

+14-20
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl Cli {
346346
"Unhandled command so unknown session name".to_string()
347347
}
348348
};
349-
session.set_name(&possiblename)?;
349+
session.set_name(&possiblename);
350350
session.name.to_string()
351351
}
352352

@@ -426,7 +426,6 @@ impl Session {
426426
/// Takes a string, applies some cleanup, then stores it as
427427
/// session name, returning the cleaned up value
428428
#[tracing::instrument(level = "trace")]
429-
#[throws(anyhow::Error)]
430429
fn set_name(&mut self, newname: &str) {
431430
// Replace a set of characters we do not want in the session name with _
432431
self.name = newname.replace(&[' ', ':', '"', '.'][..], "_");
@@ -662,7 +661,7 @@ impl Session {
662661
// as that session name. So we check again, and if
663662
// a session name like this already exists, we try
664663
// attaching to it.
665-
self.set_name(&line)?;
664+
self.set_name(&line);
666665
if self.exists() {
667666
info!("Session matches existing one, attaching");
668667
self.attach()?;
@@ -1716,19 +1715,14 @@ mod tests {
17161715
..Default::default()
17171716
};
17181717

1719-
assert_eq!("test", session.set_name("test").unwrap());
1720-
assert_eq!("test_second", session.set_name("test second").unwrap());
1721-
assert_eq!("test_third", session.set_name("test:third").unwrap());
1722-
assert_eq!(
1723-
"test_fourth_fifth",
1724-
session.set_name("test fourth fifth").unwrap()
1725-
);
1726-
assert_eq!(
1727-
"test_fourth_fifth_more_words_here_set_in",
1728-
session
1729-
.set_name("test fourth_fifth:more words here\"set in")
1730-
.unwrap()
1731-
);
1718+
session.set_name("test");
1719+
assert_eq!("test", session.name);
1720+
session.set_name("test second");
1721+
assert_eq!("test_second", session.name);
1722+
session.set_name("test:third");
1723+
assert_eq!("test_third", session.name);
1724+
session.set_name("test_fourth_fifth_more_words_here\"set_in");
1725+
assert_eq!("test_fourth_fifth_more_words_here_set_in", session.name);
17321726
}
17331727

17341728
#[test]
@@ -1756,7 +1750,7 @@ mod tests {
17561750
..Default::default()
17571751
};
17581752
// We want a new session
1759-
session.set_name("fakeattach").unwrap();
1753+
session.set_name("fakeattach");
17601754
// Shouldn't exist
17611755
assert!(!session.exists());
17621756
// Lets create it
@@ -1788,7 +1782,7 @@ mod tests {
17881782

17891783
assert!(!session.exists());
17901784
// And now we test something that shouldn't work for attach
1791-
session.set_name("notfakeattach").unwrap();
1785+
session.set_name("notfakeattach");
17921786
// Not grouped
17931787
session.grouped = false;
17941788
// Shouldn't exist
@@ -1815,7 +1809,7 @@ mod tests {
18151809
let mut session = Session {
18161810
..Default::default()
18171811
};
1818-
session.set_name("tmtestsession").unwrap();
1812+
session.set_name("tmtestsession");
18191813
assert!(!session.exists());
18201814
Tmux::with_command(
18211815
NewSession::new()
@@ -1905,7 +1899,7 @@ mod tests {
19051899
let mut session = Session {
19061900
..Default::default()
19071901
};
1908-
session.set_name("testextended").unwrap();
1902+
session.set_name("testextended");
19091903
// Fail, we have no data in session.targets yet
19101904
assert!(session.setup_extended_session().is_err());
19111905

0 commit comments

Comments
 (0)