fakehub - A fully functional fake version of a GitHub REST API that supports all the features and works locally, with no connection to GitHub at all.
Motivation. There are many applications that use GitHub API for different purposes. All of them need to create automated tests, which need to mock the API server somehow. We offer a fully functioning mock version of a GitHub REST API, which would support all functions, but work locally, with absolutely no connection to GitHub.
First, install it from crate:
cargo install fakehub
or with homebrew (macOS):
brew install fakehub
Then, run it:
fakehub start --port 8080
Table of contents:
fakehub is a full clone of GitHub REST API. This is very beneficial for testing, when you should not use real GitHub, but a mock version of it instead. fakehub stores all the data in memory. When request arrives, we query the storage, transform objects into GitHub API-compatible format (JSON) and give it to you.
fakehub supports the format specified in GitHub REST API docs.
For instance, if you want to use Get a repository
endpoint: you should just replace api.github.com
to localhost:$port
(make
sure that fakehub
is running on specified port).
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http://localhost:$port/repos/OWNER/REPO
Attention! Don't use your own GitHub Personal Access Tokens to authorize in fakehub. Instead, use generated token by fakehub:
curl -X POST \
-H "Content-Type: application/json" \
-d '{"login": "jeff"}' \
http://localhost:$port/login
This should generate you an access token to fakehub API.
We support the following list of "fake" versions of GitHub endpoints:
Operation | GitHub REST API Endpoint | Supported in fakehub |
---|
TBD..
You can use the following options within fakehub
command-line tool:
Name | Value | Default | Description |
---|---|---|---|
-p , --port |
int | 3000 |
Port to run fakehub server on. |
-v , --verbose |
boolean | false |
Verbose run output, i.e. debug logs, etc. |
-d , --detach |
boolean | false |
Run fakehub server in detached mode. |
report |
boolean | false |
Generate report after fakehub shutdown. |
report-format |
string | - | Generated report format. Possible values: latex for LaTeX, xml for XML, and txt for plain text. |
Make sure that you have Rust, just, npm, and Java 21+ installed on your
system, then fork this repository, make changes, send us a
pull request. We will review your changes and apply them to the
master
branch shortly, provided they don't violate our quality standards. To
avoid frustration, before sending us your pull request please run full build:
just full
Here is the contribution vitals, made by zerocracy/judges-action (updated every hour!).