Skip to content

Commit

Permalink
Add some custom css
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp committed Feb 11, 2023
1 parent f23319e commit f8ee3f1
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Getting Started
Installation
-------------

### GitHub Release

<small>recommended</small>

Visit the [releases page](https://github.com/vektra/mockery/releases) to download one of the pre-built binaries for your platform.

### go install

Supported, but not recommended: [see wiki page](https://github.com/vektra/mockery/wiki/Installation-Methods#go-install) and [related discussions](https://github.com/vektra/mockery/pull/456).
Expand All @@ -12,12 +18,6 @@ Alternatively, you can use the go install method to compile the project using yo

go install github.com/vektra/mockery/v2@latest

### GitHub Release

<small>recommended</small>

Visit the [releases page](https://github.com/vektra/mockery/releases) to download one of the pre-built binaries for your platform.

### Docker

Use the [Docker image](https://hub.docker.com/r/vektra/mockery)
Expand Down
65 changes: 65 additions & 0 deletions docs/mockery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
mockery
========

Mockery is a project that aims to make the generation of mock implementations of Golang interfaces. The mocks generated in this project are based off of the `github.com/stretchr/testify` suite of packages.

![](https://raw.githubusercontent.com/vektra/mockery/master/docs/Peek%202020-06-28%2000-08.gif)

Why mockery?
-------------

As described in the [documentation](https://pkg.go.dev/github.com/stretchr/testify/mock) for `github.com/stretchr/testify/mock`, fake implementations of your Golang interfaces can be manually curated. These hand-rolled mocks can utilize the `mock` package to direct your mock how it should behave once called, register calls with the package, and assert the way in which the mocks were called. Details of how those mocks are implemented will not be repeated here as it's well-documented on `testify`'s page.

Instead, we provide an automatic way of generating structs that satisfy your interfaces, and interface with `github.com/stretchr/testify/mock` automatically. The methods provided by `mock` are accessible, but we also provide a number of conveniences. Take for example this interface:

```go title="string.go"
package example_project

type Stringer interface {
String() string
}
```

From this interface, we can generate a mock implementation using Golang reflection and syntax parsing. See this abbreviated snippet that was generated by mockery:

```go title="mock_string.go"
// MockStringer is an autogenerated mock type for the Stringer type
type MockStringer struct {
mock.Mock
}

type MockStringer_Expecter struct {
mock *mock.Mock
}

// String provides a mock function with given fields:
func (_m *MockStringer) String() string {
ret := _m.Called()

var r0 string
if rf, ok := ret.Get(0).(func() string); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(string)
}

return r0
}

type mockConstructorTestingTNewMockStringer interface {
mock.TestingT
Cleanup(func())
}

// NewMockStringer creates a new instance of MockStringer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewMockStringer(t mockConstructorTestingTNewMockStringer) *MockStringer {
mock := &MockStringer{}
mock.Mock.Test(t)

t.Cleanup(func() { mock.AssertExpectations(t) })

return mock
}
```

<span>[Get Started](/mockery/installation/){ .md-button .md-button--stretch }</span>
5 changes: 5 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.md-button--stretch {
width: 100%;
text-align: center;
}

6 changes: 6 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ theme:
- navigation.tracking
- toc.follow
markdown_extensions:
- attr_list
- md_in_html
- pymdownx.highlight:
anchor_linenums: true
Expand All @@ -44,6 +45,8 @@ markdown_extensions:


nav:
- Home:
- Mockery: mockery.md
- Getting Started:
- Installation: installation.md
- Configuration: configuration.md
Expand All @@ -54,3 +57,6 @@ nav:
- Changelog: changelog.md
- Features: features.md
- Additional Notes: notes.md

extra_css:
- stylesheets/extra.css

0 comments on commit f8ee3f1

Please sign in to comment.