jrmoulton/tmux-sessionizer

Testing

Closed this issue · 3 comments

I've made several attempts to add automated testing that haven't worked out. Testing a live tmux session has been difficult because it interferes with my currently active tmux server.

Preferably I would want the testing to be able to create an entirely new tmux server and interact with it without disturbing any other active tmux servers. I'm not sure if this is possible

It should be possible to set TMUX_TMPDIR to some location (for example /tmp/tmux-testing) in order to make tmux use a separate socket in that location

Looks like you can add a -L flag to invocations of tmux to use a non-default server i.e. tmux -L tests new.

https://github.com/tmux/tmux/wiki/Advanced-Use#socket-and-multiple-servers

I'm busy having a stab at this, and making good progress. You can see my branch here.

I've refactored all the calls to tmux into a Tmux struct, which allows us to control which tmux socket we are using.

The part where I am getting stuck is actually testing the TUI. When I try invoke tms from the integration tests, I get this error:

Error: TUI error: Failed to initialize input reader

This is the part of the test that fails

I see there is a TestBackend struct in ratatui, maybe this could be useful..

I tried to look for examples of TUIs using ratatui with good integration tests but haven't found anything yet.