Skip to content

Commit 4779295

Browse files
init
0 parents  commit 4779295

File tree

13 files changed

+13970
-0
lines changed

13 files changed

+13970
-0
lines changed

.github/workflows/workflow.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Go Github Mockable
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: Set up Go
11+
uses: actions/setup-go@v3
12+
with:
13+
go-version: 1.18
14+
- name: Test
15+
run: make test

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Connor McKelvey
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.PHONY: clean
2+
clean:
3+
find . -name "*.gen.go" -type f -delete
4+
5+
.PHONY: client
6+
client:
7+
go generate .
8+
9+
.PHONY: mocks
10+
mocks:
11+
go generate ./mocks
12+
13+
.PHONY: gen
14+
gen: clean client mocks
15+
16+
.PHONY: test
17+
test: gen
18+
go test -v ./...

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Go Github Mockable
2+
3+
Go Github Mockable provides an interface-based wrapper for the [Go Github](https://github.com/google/go-github) client, making it possible to generate mocks (also included) for the client using [GoMock](https://github.com/golang/mock).
4+
5+
## Install
6+
7+
```bash
8+
$ go get github.com/connormckelvey/go-github-mockable
9+
```
10+
11+
## Usage
12+
13+
```go
14+
package main
15+
16+
import (
17+
"github.com/google/go-github/v48/github"
18+
"github.com/connormckelvey/go-github-mockable"
19+
)
20+
21+
func main() {
22+
gh := github.NewClient(nil)
23+
client := gogithubmockable.NewClient(gh)
24+
25+
26+
// Instead of client.Repositories, use client.GetRepositories()
27+
c.GetRepositories().Get(context.TODO(), "owner", "repo")
28+
...
29+
}
30+
```
31+
32+
## TODO
33+
34+
- Copy GoDoc comments from source (DX)
35+
- Add names to interface method definitions (DX)

0 commit comments

Comments
 (0)