Bhupesh-V / ugit

🚨️ ugit helps undo git commands. Your damage control git buddy. Undo from 20+ git scenarios.
https://bhupesh.me/undo-your-last-git-mistake-with-ugit/
MIT License
1.36k stars 44 forks source link

write tests using `bats` framework #19

Open Bhupesh-V opened 3 years ago

Bhupesh-V commented 3 years ago

Ever wrote tests for a script? We need to use bats Check out projects using bats for examples

Since this is a weird use case, we need to figure out what things to test or not. Suggestions are welcome

kopalchakravarty commented 1 year ago

@Bhupesh-V I'd like to work on this.

Do you have something in mind that we could use as a baseline?

Bhupesh-V commented 1 year ago

@Bhupesh-V I'd like to work on this.

Do you have something in mind that we could use as a baseline?

Hey have been doing some research, seems like there is lot to think about. The fundamental problem to figure out is how do we mock the execution of fzf command in bats. Since its deeply integrated within ugit.

Another tool I tried using was shellspec for testing, but as it turns out it doesn't support testing colored output. Ref: https://github.com/shellspec/shellspec/issues/278

Not really sure how to proceed further at the moment. If you are able to find something, do let me know in the thread.

LukeSavefrogs commented 1 year ago

Another tool I tried using was shellspec for testing, but as it turns out it doesn't support testing colored output. Ref: https://github.com/shellspec/shellspec/issues/278

See my answer on that issue...

The solution to make it work is to use custom matchers.