Skip to content

Commit

Permalink
Merge pull request #546 from LandonTClipp/mkdocs3
Browse files Browse the repository at this point in the history
Fix indexing for ghpages
  • Loading branch information
LandonTClipp committed Feb 11, 2023
2 parents 999fd76 + f056a3a commit 8bb1387
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 67 deletions.
62 changes: 62 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +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
}
```

[Get Started](/mockery/installation/){ .md-button .md-button--stretch }
65 changes: 0 additions & 65 deletions docs/mockery.md

This file was deleted.

3 changes: 1 addition & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ markdown_extensions:


nav:
- Home:
- Mockery: mockery.md
- Home: index.md
- Getting Started:
- Installation: installation.md
- Configuration: configuration.md
Expand Down

0 comments on commit 8bb1387

Please sign in to comment.