Skip to content

Commit

Permalink
This commit does the following:
Browse files Browse the repository at this point in the history
- fix a type preventing test suites from being run on `cargo test`. `[#cfg(tests)] becomes `[cfg(test)]`
- fix tests that stopped working after recent changes to tags
  • Loading branch information
PVautour committed Feb 18, 2021
1 parent 10e24ff commit 2f24a15
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/handlers/focus_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub fn update_current_tags(manager: &mut Manager) {
}
}

#[cfg(tests)]
#[cfg(test)]
mod tests {
use super::*;

Expand Down Expand Up @@ -281,7 +281,7 @@ mod tests {
screen_create_handler::process(&mut manager, Screen::default());
screen_create_handler::process(&mut manager, Screen::default());
let mut window = Window::new(WindowHandle::MockHandle(1), None);
window.tag("2".to_owned());
window.tag("2");
focus_window(&mut manager, &window, 0, 0);
let actual = manager.focused_tag().unwrap();
assert_eq!("2", actual);
Expand All @@ -294,7 +294,7 @@ mod tests {
screen_create_handler::process(&mut manager, Screen::default());
screen_create_handler::process(&mut manager, Screen::default());
let mut window = Window::new(WindowHandle::MockHandle(1), None);
window.tag("2".to_owned());
window.tag("2");
focus_window(&mut manager, &window, 0, 0);
let actual = manager.focused_workspace().unwrap().id.clone();
let expected = manager.workspaces[1].id.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/goto_tag_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn process(manager: &mut Manager, tag_num: usize) -> bool {
true
}

#[cfg(tests)]
#[cfg(test)]
mod tests {
use super::*;

Expand Down
8 changes: 4 additions & 4 deletions src/handlers/screen_create_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn process(manager: &mut Manager, screen: Screen) -> bool {
false
}

#[cfg(tests)]
#[cfg(test)]
mod tests {
use super::*;

Expand All @@ -39,9 +39,9 @@ mod tests {
#[test]
fn should_be_able_to_add_screens_with_perexisting_tags() {
let mut manager = Manager::default();
manager.tags.push("web".to_owned());
manager.tags.push("console".to_owned());
manager.tags.push("code".to_owned());
manager.tags.push(TagModel::new("web"));
manager.tags.push(TagModel::new("console"));
manager.tags.push(TagModel::new("code"));
process(&mut manager, Screen::default());
process(&mut manager, Screen::default());
assert!(manager.workspaces[0].has_tag("web"));
Expand Down
2 changes: 1 addition & 1 deletion src/models/dock_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl DockArea {
}
}

#[cfg(tests)]
#[cfg(test)]
mod tests {
use super::*;

Expand Down
15 changes: 6 additions & 9 deletions src/models/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,27 +263,24 @@ impl Window {
}
}

#[cfg(tests)]
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn should_be_able_to_tag_a_window() {
let mut subject = Window::new(WindowHandle::MockHandle(1), None);
subject.tag("test".to_string());
assert!(
subject.has_tag("test".to_string()),
"was unable to tag the window"
);
subject.tag("test");
assert!(subject.has_tag("test"), "was unable to tag the window");
}

#[test]
fn should_be_able_to_untag_a_window() {
let mut subject = Window::new(WindowHandle::MockHandle(1), None);
subject.tag("test".to_string());
subject.untag("test".to_string());
subject.tag("test");
subject.untag("test");
assert!(
subject.has_tag("test".to_string()) == false,
subject.has_tag("test") == false,
"was unable to untag the window"
);
}
Expand Down

0 comments on commit 2f24a15

Please sign in to comment.