Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test git module #374

Merged
merged 5 commits into from
Aug 12, 2023
Merged

Test git module #374

merged 5 commits into from
Aug 12, 2023

Conversation

korthout
Copy link
Owner

Refactors parts of the code to make it easier to write tests, and adds several simple test cases for the git module.

This is part of an attempt to improve the testability of this project.

This will make it easier to inject execa into git and to inject git into
backport.
Inversion of control makes it easier to test backport.ts and git.ts.

I had to add a bit of a strange type for execa, using the import()
function. This is because execa does not provide the types in an easily
importable way. If you know of a better way to do this, please let me
know.

The idea of this type is to take the type of the import of execa, which
is an object that contains all the functions of the execa package.

```
type Execa = (typeof import("execa"))...
```

Then, we take the `execa` function from this object using an indexed
access type:

```
type Execa = ...["execa"]
```
Adds some tests to make sure git works as I expect
Adds another simple test case that shows that cherryPick can throw an
error when it exits with a non-zero exit code.
It's not longer necessary to mock away execa
@korthout korthout merged commit a397c99 into main Aug 12, 2023
1 check passed
@korthout korthout deleted the test-git branch August 12, 2023 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant