chshersh / zbg

✨ Zero Bullshit Git
Mozilla Public License 2.0
187 stars 11 forks source link

Write tests for 'zbg commit' #22

Closed chshersh closed 11 months ago

chshersh commented 1 year ago

To make sure that escaping works as expected

https://github.com/chshersh/zbg/blob/b9be80fa391a35f6ef20a4ff24af3a91c6d950fc/lib/git.ml#L66-L71

LeedsJohn commented 11 months ago

Hi! Do you mind elaborating on what behavior you would like there to be tests for? There are already tests written for Extended_string.unwords so I am confident that works as expected.

In order to test the Printf.sprintf "git commit --message=%S" message line, I think it would make sense to pull that out into a val get_commit_message : string -> string function and either expose it in git.mli so you could add a test in the tests folder (which I don't think is a good decision) or write an in file expect test (which I don't necessarily think is a bad decision but haven't seen that used previously in the project). Then, after the git add . line, you could write Process.proc @@ get_commit_message message

I actually think that this function might be fine without a test because the Printf documentation says that %S will convert a string to an OCaml string with escapes (which I confirmed when playing around in utop).

Let me know what you think - thanks!

chshersh commented 11 months ago

@LeedsJohn Thanks for brining this issue up!

Actually, I think this issue can be closed as withdrawn.

I believe I created it with the context that the escaping function will contain some complicated logic, and it'll make sense to test it. But since the implementation by @paulpatault was really elegant, I agree that we shouldn't spend time on testing dependencies.

Closing as resolved!