Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #87

Merged
merged 10 commits into from
Mar 4, 2024
Merged

Add tests #87

merged 10 commits into from
Mar 4, 2024

Conversation

emilioziniades
Copy link
Contributor

This PR sets the foundation for testing tms. It does a few things:

  1. It removes the execute_tmux_command function, and instead creates a Tmux struct, whose methods expose an API for tmux commands. This allows us to control which tmux socket is being used, and this in turn opens up the possibility of testing tms on a non-default tmux socket. As a side benefit, it cleans up the codebase a bit and eliminates a lot of format! based string interpolation that was needed to use execute_tmux_command.
  2. It transforms the crate into a dual binary-library crate. This allows us to stick all the tests into a top-level tests directory and use structs and functions from the crate, as I do when testing the tms config command. I pretty much just took everything that wasn't fn main in main.rs and stuck it in lib.rs.
  3. It adds the first two integration tests.
  4. It adds a ci workflow for running integration tests.

There are still a few more tests I wanted to write, but my branch was drifting from main, and since there are two tests here, I thought it made sense to make a PR.

cc @jrmoulton @junglerobba

This is the first step to making this crate more testable.
In order to test this crate, we need to be able to execute tmux
commands against a tmux socket that is not the one we are currently in.

Currently, `execute_tmux_command` is used to interact with tmux,
and this makes it difficult to test because you would have to manually
add `-L test-socket` to each invocation of that method.

By creating a tmux struct and storing the socket name in there, it
becomes possible to test.
create a lib.rs so that we can access modules from the unit
tests as well as the main.rs
@jrmoulton
Copy link
Owner

Ahh yeah this will be nice. Much improved.

I'll also work on adding some tests. When I start working on them I'll open a tracking issue and say which tests I'm working on.

These look like really great changes to me. Thanks!

@jrmoulton jrmoulton merged commit 3611edb into jrmoulton:main Mar 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants