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

github.Client: Add tests #410

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

abhinav
Copy link
Contributor

@abhinav abhinav commented Jun 14, 2024

Adds some simple end-to-end tests for the GitHub client
to avoid breaking this with other planned changes.

This introduces a new test dependency dnaeon/go-vcr,
but it's a pretty small surface area,
and go-vcr itself only depends on yaml.v3.

The way the test works is pretty straightforward:

  • In record mode (enabled with go test -update)
    actual requests are made to GitHub and recorded into testdata files.
  • In replay mode (the default),
    the HTTP client only replays the previously recorded interactions,
    and rejects any new requests.
    So tests will not make actual requests to GitHub after first run.

This test exposed a small bug in GitHub client initialization:
It ignored the supplied client if a token was not provided.
This change fixes that bug as well.

@abhinav abhinav changed the title github.Client: Add end-to-end tests github.Client: Add tests Jun 14, 2024
Adds some simple end-to-end tests for the GitHub client
to avoid breaking this with other planned changes.

This introduces a new test dependency [dnaeon/go-vcr][1],
but it's a pretty small surface area,
and go-vcr itself only depends on yaml.v3.

  [1]: https://github.com/dnaeon/go-vcr

The way the test works is pretty straightforward:

- In record mode (enabled with `go test -update`)
  actual requests are made to GitHub and recorded into testdata files.
- In replay mode (the default),
  the HTTP client only replays the previously recorded interactions,
  and rejects any new requests.
  So tests will not make actual requests to GitHub after first run.

This test exposed a small bug in GitHub client initialization:
It ignored the supplied client if a token was not provided.
This change fixes that bug as well.
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