tj / git-extras

GIT utilities -- repo summary, repl, changelog population, author commit percentages and more
MIT License
17.29k stars 1.21k forks source link

Test(git-brv): add unit test #1131

Open vanpipy opened 8 months ago

vanpipy commented 8 months ago

File

git-brv

Testcases

  1. If the repository has only one branch and its name is main, when invoke the git-brv command, the format of the result is {date} {branch_name} {upstream} {branch_short_hash} {commit_title_message} and output is just like 2024-01-05 main origin/main b54d8c7 test(git-browse): add unit tests (#1127)
  2. If the repository has multiple branches and the names are feature/2024-01-01, feature/2024-01-02, feature/2024-01-03 and suppose the branches created date are same to the branch name, when invoke the git-brv command, the result is
{date} feature/2024-01-03 {upstream} {branch_short_hash} {commit_title_message}
{date} feature/2024-01-02 {upstream} {branch_short_hash} {commit_title_message}
{date} feature/2024-01-01 {upstream} {branch_short_hash} {commit_title_message}
  1. Suppose the same as 2 and invoke the git-brv with --reverse argument, the result is
{date} feature/2024-01-01 {upstream} {branch_short_hash} {commit_title_message}
{date} feature/2024-01-02 {upstream} {branch_short_hash} {commit_title_message}
{date} feature/2024-01-03 {upstream} {branch_short_hash} {commit_title_message}

PS: It is a curious command, but I am more curious about the command name, what is the full name of the git-brv? The brv is not easy to explain the thing done with it.

Reference

vanpipy commented 1 day ago

Sorry for the late, and I will switch the pytest to shellspec cause do the code coverage generation hardly. I research lots of the existing unit test framework, then found the shellspec. It is suitable for our process to do unit test, but i will do more function testes and to rewrite the existing unit testes to test with it.

hyperupcall commented 1 day ago

@vanpipy What do you think about Bats? It's much more popular and more maintained (last release was in 2024 instead of shellspec's 2021). I'm really not personally a fan of shellspec's BDD-style tests, which I find hard to read and might discourage new contributors from adding to it. For code coverage for Bats, it looks like bashcov can be helpful.

To be honest, I have kind of been avoiding the pytest stuff in this repository because I had a difficult time working with it and reading it (compared to Bats). That made me wish I pushed for using Bats for testing a little harder.

If you are okay with switching to Bats (instead of shellspec) I would be able to help set things up! I've used Bats for dozens of projects so it's kind of like second-nature to me.

cc @spacewander

spacewander commented 1 day ago

I will vote for Bats too. It is used more widely.

vanpipy commented 17 hours ago

@vanpipy What do you think about Bats? It's much more popular and more maintained (last release was in 2024 instead of shellspec's 2021). I'm really not personally a fan of shellspec's BDD-style tests, which I find hard to read and might discourage new contributors from adding to it. For code coverage for Bats, it looks like bashcov can be helpful.

Yes, it is great one, i forget the starred one. It is the one choice i try to test.

bashcov it good for git-extras, but i took an error start point.. thanks a lot.

If you are okay with switching to Bats (instead of shellspec) I would be able to help set things up! I've used Bats for dozens of projects so it's kind of like second-nature to me.

Great, many thanks for this again. I think there is still a seperated test directory for the all unit tests. I will to do the research about the Bats together!

I think there are some concerns here,

  1. git-extras has the unit test files only
  2. Installing the bats easily when needed
  3. Good way or practice to extend the test utils

I have the answer for 1, but cannot answer the 2 and 3 even i review the bats document.