Skip to content

Commit

Permalink
tests(variables): fix conditionals in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonGepting committed Feb 10, 2024
1 parent d0a41d7 commit 36f92ab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/variables/buffer/buffers_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ fn buffers_parse() {
let buffers_str = format!("{}\n{}", buffer0_str, buffer1_str);
let buffers = Buffers::from_str(&buffers_str).unwrap();

#[cfg(feature = "tmux_2_3")]
assert_eq!(buffers[0].name, Some("foo1".to_string()));
#[cfg(feature = "tmux_2_3")]
assert_eq!(buffers[1].name, Some("foo2".to_string()));
}
3 changes: 3 additions & 0 deletions src/variables/buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ pub mod buffer;
pub mod buffers;
pub mod buffers_ctl;

#[cfg(feature = "tmux_1_7")]
pub use buffer::Buffer;
#[cfg(feature = "tmux_1_7")]
pub use buffers::Buffers;
#[cfg(feature = "tmux_1_7")]
pub use buffers_ctl::BuffersCtl;

#[cfg(test)]
Expand Down
3 changes: 3 additions & 0 deletions src/variables/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ pub mod client;
pub mod clients;
pub mod clients_ctl;

#[cfg(feature = "tmux_1_6")]
pub use client::Client;
#[cfg(feature = "tmux_1_6")]
pub use clients::Clients;
#[cfg(feature = "tmux_1_6")]
pub use clients_ctl::ClientsCtl;

#[cfg(test)]
Expand Down
17 changes: 11 additions & 6 deletions tests/variables_ctl/buffers_ctl_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ fn get_buffers() {
.output()
.unwrap();

#[cfg(feature = "tmux_2_3")]
Tmux::with_command(SetBuffer::new().buffer_name(BUFFER_NAME).data(BUFFER_NAME))
.output()
.unwrap();

let buffers = BuffersCtl::new().get_all().unwrap();
let mut found = false;
for buffer in buffers {
if buffer.name == Some(BUFFER_NAME.to_string()) {
found = true;
#[cfg(feature = "tmux_2_3")]
{
let buffers = BuffersCtl::new().get_all().unwrap();
let mut found = false;
for buffer in buffers {
if buffer.name == Some(BUFFER_NAME.to_string()) {
found = true;
}
}
assert!(found);
}
assert!(found);

#[cfg(feature = "tmux_2_3")]
Tmux::with_command(DeleteBuffer::new().buffer_name(BUFFER_NAME))
.output()
.unwrap();
Expand Down

0 comments on commit 36f92ab

Please sign in to comment.