matchai / spacefish

🚀🐟 The fish shell prompt for astronauts
https://spacefish.matchai.dev
MIT License
963 stars 79 forks source link

Add tests for git status section #120

Closed matchai closed 5 years ago

matchai commented 5 years ago

Description

The git status section has a fair bit of complexity and should probably be tested. In the process of writing these tests, I found a few issues in other existing tests.

Motivation and Context

Improve that test coverage! ⬆️

Types of changes

How Has This Been Tested?

Checklist:

Snuggle commented 5 years ago

Are you stuck on anything in particular here? :blush:

matchai commented 5 years ago

Thanks for asking. 😄 Mostly the tests that I've mentioned in these comments: https://github.com/matchai/spacefish/blob/792ba48382d2ae7ffc5311ebbd9256f51392185e/tests/__sf_section_git_status.test.fish#L120-L123

I was thinking of doing some work on our mock util to allow for more flexible mocks so that we can properly test these (e.g. specifying the command and argument necessary to trigger a mock).

Snuggle commented 5 years ago

Oh, heh. It might be better to have a checklist in the PR for to-do lists in the future! 😊

And I'd love such an improvement, would make things much easier!

matchai commented 5 years ago

Gah! After all this work rewriting our mocking library, I just realized that we use command git in the git section, so we can't mock it! 😖

@Snuggle Any ideas as to how we can achieve these test states? I'm considering just merging this in for now. It's definitely a step above what we used to have for git status testing.

matchai commented 5 years ago

I'll just go ahead and merge this in how it is, once I get a review. 😄

Snuggle commented 5 years ago

Could I ask what this \* syntax does? Is it globbing a bunch of files in a directory or...?

https://github.com/matchai/spacefish/blob/74dec4a89b946ee9aa36beca8ac1650a9e3efe1f/tests/__sf_section_aws.test.fish#L6

I'd also like to note that on this line just, cd, should suffice. It always defaults to home anyways! https://github.com/matchai/spacefish/blob/74dec4a89b946ee9aa36beca8ac1650a9e3efe1f/tests/__sf_section_dir.test.fish#L31

matchai commented 5 years ago

Be sure to use the handy "No Whitespace" button when reviewing this. The bulk of the diff is really just whitespace changes 😅

image

Snuggle commented 5 years ago

I cannot see this button? Are you enrolled in one of the fancy GitHub beta experiments?

screenshot_20181209-191230

matchai commented 5 years ago

Oh haha. I've been using Refined GitHub for so long that I didn't realize that this wasn't a core GitHub feature. 😅 I highly recommend it though!